[Image-SIG] Saving jpeg files with optimization

Najmuddin Fakhruddin nfakh@bom2.vsnl.net.in
Sat, 14 Aug 1999 01:15:42 +0530


Fredrik Lundh wrote:
> 
> 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)
> 
> </F>

Thanks. I tried this and it does fix the problem.

Najmuddin