python image to png code example

Example 1: python pillow convert jpg to png

from PIL import Image

im1 = Image.open(r'C:\Users\Ron\Desktop\Test\autumn.jpg')
im1.save(r'C:\Users\Ron\Desktop\Test\new_autumn.png')

Example 2: python pillow convert jpg to png

from PIL import Image

im1 = Image.open(r'path where the JPG is stored\file name.jpg')
im1.save(r'path where the PNG will be stored\new file name.png')

Example 3: save image url to png python

import urllib.request

#python 3
urllib.request.urlretrieve(url, filename)