[Image-SIG] im.save("xyz.jpg") - quality?

Fredrik Lundh fredrik@pythonware.com
Thu, 15 Jul 1999 03:02:29 +0200


im.save("xyz.jpg") - quality?Turner, Kingsley wrote:
> Is there any way to configure the way the PIL saves jpegs ? 
> I've got some code to make thumbnails (ok, it's almost the 
> same as in the manual).  
> I'd really like to minimise the file size said thumbnails, and the 
> best way to do this is use the JPEG 'optimise' feature of the encoder 
> and to set the JPEG quality to about 50%.  (50% is a bit dodgey for 
> reproduction, but fine for thumbs) 
> Does the PIL automatically do 'optimized' jpeg saves ? 
> Is there a way I can adjust the quality factor for the compression 
> algorithm ? 

try:

    im.save("xyz.jpg", quality=50, optimize=1)

for details, see the description of the save method at:
http://www.pythonware.com/library/pil/handbook/image.htm
the available save options are found here:
http://www.pythonware.com/library/pil/handbook/formats.htm

<F href="http://www.pythonware.com/people/fredrik/busy.htm">