Tesseract For PHP error - Error in pixReadMemPng: tmpfile stream not opened

328 views
Skip to first unread message

Mike Tsai

unread,
Jul 1, 2016, 2:10:47 AM7/1/16
to tesseract-ocr
Hi,

I am currently having issue using Tesseract For PHP (https://github.com/thiagoalessio/tesseract-ocr-for-php) as I can't understand what the error means found in the error log of XAMPP server. >>
Warning in pixReadMemPng: work-around: writing to a temp file
Error in pixReadMemPng: tmpfile stream not opened
Error in pixReadMem: png: no pix returned
Error during processing.

I have installed the Tesseract OCR on the local machine, and test it out using Terminal, and it works perfectly. I could see the out.txt being created in the same folder as the image being rendered.
However, when I try to OCR the image via php in browser, it will not work, and throw the error stated above.

I am not sure what am I missing here?
If you can share me some light on this, it will be very helpful.

The below is the steps that I did:

1) Installed TesseractOCR on OSX using MacPort
$ tesseract -v

tesseract 3.04.00

 leptonica-1.73

  libgif 4.2.3 : libjpeg 9a : libpng 1.6.23 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.5.0 : libopenjp2 2.1.0


2) Run and install Composer dependancy as the instruction and  then add the following code into index.php


require_once __dir__ . '/vendor/autoload.php';

echo (new TesseractOCR('text.png'))

->executable('/opt/local/bin/tesseract')

->run();



Thanks


Regards,

Mike


Kyle Schultz

unread,
Jul 1, 2016, 9:29:23 AM7/1/16
to tesseract-ocr
replace text.png with the full source of the directory

Jeff Breidenbach

unread,
Jul 7, 2016, 2:58:27 PM7/7/16
to tesseract-ocr
Go ahead and take this question to the tesseract-ocr-for-php developers.
From your error messages, you are running on a platform that
doesn't support fmemopen. If Windows, then there is trouble with
Leptonica's fallback function fopenWriteWinTempfile(). If Linux, then 
somehow PHP is restricting the call to tmpfile().

Anyway, start with the tesseract-ocr-for-php developers, and if they need 
a change to Leptonica have them get in direct contact with me or
the Leptonica author. This is probably not something you can solve for 
yourself as a user.

Reply all
Reply to author
Forward
0 new messages