openpaperwork / pyocr

A Python wrapper for Tesseract and Cuneiform -- Moved to Gnome's Gitlab
https://gitlab.gnome.org/World/OpenPaperwork/pyocr
930 stars 152 forks source link

Tesseract test fails on test_orientation_90, KeyError "Uknown Extension" #29

Closed jalavosus closed 9 years ago

jalavosus commented 9 years ago
Error output:
Tesseract:
........................E
======================================================================
ERROR: test_orientation_90 (tests.tests_tesseract.TestOrientation)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/james/pyocr/tests/tests_tesseract.py", line 352, in test_orientation_90
    result = tesseract.detect_orientation(img, lang='eng')
  File "src/pyocr/tesseract.py", line 159, in detect_orientation
    image.save(proc.stdin, format=image.format)
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1453, in save
    raise KeyError(ext) # unknown extension
KeyError: ''

I'm using the python-imaging library from Ubuntu's repositories. This is the only test that fails. Please advise on how to fix.

jflesch commented 9 years ago

Hm, weird. It looks like your python-imaging lacks PNG support.

jflesch commented 9 years ago

in src/pyocr/tesseract.py, you can try replacing

    image.save(proc.stdin, format=image.format)

by something like

    image.save(proc.stdin, format='bmp')

Update: wrong version of Pyocr --> fixed.

jalavosus commented 9 years ago

This is interesting; my version of Image does support PNG -- it actually has more trouble with JPG's than it does PNG's.

Nothing's broken besides the last test, so I won't worry about it. Closing the issue.