[Image-SIG] PIL and rendering images

Jeffrey Kunce kuncej@mail.conservation.state.mo.us
Tue, 07 Aug 2001 10:03:08 -0500


> ...I'm using PIL/Python to generate jpeg backgrounds (Just haven't =
changed JPEG to PNG yet)

That's your problem :-)

jpeg uses a lossy compression scheme, i.e. data_in !=3D data_out
that's fine for most photos, but no good for diagrams (or anything
else with sharp edges that must be reproduced exactly.)

Try adding these lines to the end of your program:

im.save(infile+'.png')
im.save(infile+'.tif')
im.save(infile+'.bmp')
for q in (20,40,60,80,100):
    im.save('%s%03d.jpg'%(infile,q), quality=3Dq)
im.save(infile+'.gif')

You'll find that the PNG, TIF, and BMP files are all perfect.=20
All of those methods save the image exactly as generated

The JPG files get better as the quality increases. When you
get to Quality=3D100 (no compression) the image is perfect.

The GIF file should be perfect, but isn't on my machine.
But PIL has always had incomplete support for GIF.

  -Jeff