Automatically convert PNG to JPG using Python

I wrote a Python program to extract an image from a URL using

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

The image I get from the URL is in PNG format, but I would like to embed a JPG version in it. Is there an easy way to automatically convert PNG msgImage to JPG for small attachments?

Thank you for reading. Any help is appreciated.

+4
source share
1 answer

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

+1
source

Source: https://habr.com/ru/post/1335050/


All Articles