[Image-SIG] Opening and saving quality JPEG files

Rob Ballou web at contrastsweb.com
Thu Jun 23 21:54:58 CEST 2005


Hello,

I'm new to using PIL and I have what I hope is a quick question.

I have created a script for displaying images to a web browser and I 
have noticed that the quality PIL saves JPEGs isn't entirely what I'm 
after. When displaying thumbnails (the main use of the script), the 
quality is great. But when displaying a full size image without 
modification, I noticed that there is some new JPEG compression taking 
place (there are pronounced JPEG compression artifacts).

The code that I have is:


im = Image.open(file)
print "Content-type: image/%s\r\n" % im.format.lower()
out= cStringIO.StringIO()
im.save(out, format, quailty=100, optimize=1)
out.reset()
print out.read()
out.close()


Changing quality and the optimized attributes have little to no effect 
on the visual appearance of the image. I've tried to read the file 
directly in binary mode and print that back to the browser, but it can 
not display the image.

I'm not really sure if I am going about these changes in the best 
manner. Thanks in advance for any help.

Rob



More information about the Image-SIG mailing list