[Image-SIG] Saving jpeg files with optimization

Najmuddin Fakhruddin nfakh@bom2.vsnl.net.in
Wed, 11 Aug 1999 00:04:37 +0530


Hello,

I get an error if I try to save jpeg files with the optimize option,
unless the size of the image is quite small. The examples that I've
tried seem to suggest that the error occurs when the width or height
is greater than about 500. (The error disappears if the image is
resized to make it smaller, so I don't think it's a problem with the
images themselves.)

I'm using the 1.0 release of PIL with Python 1.5.2 on Linux (Red Hat 5.2).
The traceback is attached below.

Thanks,
Najmuddin

>>> im.size
(544, 459)
>>> im.save("new.jpg", optimize=1)
Suspension not allowed here
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  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