Convert all images to JPEG
Leif K-Brooks
eurleif at ecritters.biz
Tue Dec 28 19:51:09 EST 2004
Thomas wrote:
> im = Image.open(srcImage) # might be png, gif etc, for instance
> test1.png
> im.thumbnail(size, Image.ANTIALIAS) # size is 640x480
> im.save(targetName, "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