[Image-SIG] PIL with JPEG support on Windows: Error Writing JPEG file

Bryan Jeal bryan at hideawaystudios.com
Tue Mar 24 17:15:18 CET 2009


GOAL: Have a website built on the Django framework running under  
Windows Server 2003 (Apache with mod_python and MySQL) be able to  
upload pictures and then create a tinted thumbnail using PIL. I have  
all the code working and I have everything (python, PIL, django,  
apache and MySQL) setup and working on a linux machine; however, I  
HAVE to get it working on Windows.

PROBLEM: PIL with Jpeg support on Windows...

After much fighting with the Jpeg Library and PIL here is what I have  

Step 1: From Windows: Install python-2.5.4.msi with default settings,  
install Mingw32 and install Cygwin

Step 2: Start Cygwin and extract, './configure --enable-shared -- 
enable-static CC="gcc -mno-cygwin" CXX="gcc -mno-cygwin"', make, make - 
n install, make -n install-lib for jpeg-6b and extract, ./configure,  
make, make install for zlib

Step 3: From Windows: extract Imaging-1.1.6.tar.gz and edit setup.py  
to point to jpeg-6b and zlib library locations (ex. JPEG_ROOT = "C:\ 

Step 4: From Windows: 'python setup.py build -c mingw32 install' the  
Imaging 1.1.6 package

Step 5: From Windows: 'python selftest.py' (NOTE: When building  
Imaging 1.1.6 jpeg and zlib support are OK) 57 tests passed for  
Imaging 1.1.6 package

Step 6: From Windows: 'python' then:
  >>> import Image
  >>> im = Image.open('c:/temp/testimage.jpg')
  >>> im.size[0] 									(result: 932)
  >>> tmpFile = open('C:/temp/temp_win.jpg', 'w')
  >>> im.save(tmpFile, 'JPEG', quality=90) 			(result: See Below)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\Python25\lib\site-packages\PIL\Image.py", line 1405, in save
     save_handler(self, fp, filename)
   File "C:\Python25\lib\site-packages\PIL\JpegImagePlugin.py", line  
409, in _save
     ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
   File "C:\Python25\lib\site-packages\PIL\ImageFile.py", line 491, in  
     s = e.encode_to_file(fh, bufsize)
IOError: [Errno 0] Error

After finally getting over the _imaging C module is not installed  
(even though an _imaging.dll existed - Python2.5 seems to only like  
_imaging.pyd) and successfully opening and reading a JPEG (I had  
numerous other errors when I tried to get this working before) file I  
am so very lost. Please help!



More information about the Image-SIG mailing list