# [Image-SIG] Jpeg not working correctly with Python 2.7 and PIL

Thu Apr 12 16:04:17 CEST 2012

Hello - I've spent the better part of the last day re-installing python
2.7 (from windows binaries from both activestate and python.org) and
PIL. I've done this on two Win7 machines, one 64-bit and one 32-bit. On
the 64bit machine, I've installed (and uninstalled) both the 32bit and
64bit versions of python (again, both activestate and python.org binaries).

Everything in python and pil works as expected except that certain calls
in pil return the error related to the jpeg decoder (IOError: decoder
jpeg not available).

I've spent hours searching through forums trying to find the fix but no
luck. It appears that this type of error has been present for years but
not everyone encounters it (based on what I'm seeing in the forums). It
also appears that those that do encounter it must resort to tweaking the
source and re-compiling pil. Note: I do not know (or really want to
know) how to compile from source which is why I'm using the binaries...

I've done enough trial and error testing that I believe:
- this issue is not unique to my system and
- that a significant portion of other people are also encountering it and
- that no "easy" (or at least non-techie) fix is available on the net  -
and please spare me the "real men compile from source" comments :)

Brian

Current Python version is: Python 2.7.3 (default, Apr 10 2012, 23:31:26)
[MSC v.1500 32 bit (Intel)] on win32

Simple code to reproduce problem:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
import Image
path_filename_big = "c:\\temp\image\\big\\test_big.jpg"
path_filename_small = "c:\\temp\image\\small\\test_small.jpg"

def image_to_thumbnail(image_file):
im = Image.open(image_file)
size = 50,70
im.thumbnail(size, Image.ANTIALIAS)
im.save(path_filename_small)

image_to_thumbnail(path_filename_big)
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Traceback (most recent call last):
File "T:/Dropbox/Dev_Gsi/Python/testing/Testing.py", line 41, in <module>
image_to_thumbnail(path_filename_big)
File "T:/Dropbox/Dev_Gsi/Python/testing/Testing.py", line 37, in
image_to_thumbnail
im.thumbnail(size, Image.ANTIALIAS)
File
"C:\Users\brayb\AppData\Roaming\Python\Python27\site-packages\PIL\Image.py",
line 1559, in thumbnail