python convert 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: Python convert dcm to png

med2image -i SAG-anon/0001-1.3.12.2.1107.5.2.19.45152.2013030808110258929186035.dcm \
          -d dicom-results/tags                        \
          -o %PatientName%PatientID%ProtocolName.jpg   \
          -s m