PIL (jpeg optimization)

Alexander Voynow sasha at ofoto.com
Thu Aug 19 02:23:54 CEST 1999


Hi:

    I'm currently using PIL to resize a lot of fairly large jpegs (300 - 500
kbytes).
Im running into odd behavior with regard to the optimize argument for the
save method

myimage.save("mynewfilename.jpg", quality=80, optimize=1)

This seems to work sometimes and not others. Without the optimize arg it
works
without fail. There *seems* to be some correlation with file size. When it
gets too
far above 300k is when it seems to gack, as follows:

    self.draft.save(self.new_path, quality=80, optimize=1)
  File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 666, in
save
    SAVE[string.upper(format)](self, fp, filename)
  File "/usr/local/lib/python1.5/site-packages/PIL/JpegImagePlugin.py", line
307, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/usr/local/lib/python1.5/site-packages/PIL/ImageFile.py", line 370,
in _save
    raise IOError, "encoder error %d when writing image file" % s
IOError: encoder error -2 when writing image file

Has anybody encountered this? Any thoughts, ideas?


I am using the latest PIL 1.0 final
Python 1.5.2
Solaris

Thanks

Sasha

sasha at ofoto.com






More information about the Python-list mailing list