Running this command in Windows shell:
djpeg -pnm -gray text.jpg | gocr -
works as expected - the image is decoded by djpeg
executable and passed to gocr
which decodes the contents.
I would like to run similar to this task under Python - pipe PIL image to gocr
without writing temp files. For example I can instruct PIL to write the image in PPM format (accepted by gocr
executable) to stdin:
im.save(sys.stdin, 'PPM')
but anything I tried with pipes and subprocess module, gives me no joy.
Can someone suggest how to run this task through Python - pipe image from PIL to executable and get the text output from stdout?