Convert all images to JPEG

Leif K-Brooks eurleif at
Wed Dec 29 01:51:09 CET 2004

Thomas wrote:
> im = # might be png, gif etc, for instance
> test1.png
> im.thumbnail(size, Image.ANTIALIAS) # size is 640x480
>, "JPEG") # targetname is test1.jpg
> produces an exception. Any clues?

The problem is that test1.png is a paletted image, and JPEGs can only 
hold true-color images. Try changing the last line to:

im.convert('RGB').save(targetName, 'JPEG')

More information about the Python-list mailing list