[Image-SIG] Saving jpeg files with optimization

Fredrik Lundh fredrik@pythonware.com
Fri, 13 Aug 1999 19:01:33 +0200

Najmuddin Fakhruddin <nfakh@bom2.vsnl.net.in> wrote:
> 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.)

after some digging, this seems to be a limitation in
the JPEG library (incremental decoding doesn't work
with optimize).

you might be able to work around this by making
PIL's output buffer large enough to hold the entire
output image:

import ImageFile
ImageFile.MAXBLOCK = 1000000 # default is 64k

im.save("file.jpg", optimize=1)