Jimmerson
Jimmerson

Reputation: 41

Automatically Convert PNG to JPG with Python

I've written a Python program to retrieve an image from a URL using

msgImage = MIMEImage( urllib2.urlopen(chartURL).read() )
msgRoot.attach(msgImage)

The image that I get from the URL is in PNG format, but I would like to embed a JPG version of it. Is there a simple way to automatically convert the PNG msgImage into JPG for smaller attachments?

Thanks for reading. Any help is greatly appreciated.

Upvotes: 4

Views: 2582

Answers (1)

Mariy
Mariy

Reputation: 5924

You can use PIL: http://www.pythonware.com/products/pil/ It is easy and it has a lot of documentation.

Upvotes: 1

Related Questions