Ben Chuanlong Du's Blog

It is never too late to learn.

Convert a PNG Image to the JPG Format Using Pillow in Python

In [5]:
import numpy as np
from PIL import Image
In [6]:
img = Image.open("../../home/media/poker/4h.png")
img
Out[6]:
In [7]:
img.save("4s.jpg")
In [8]:
!file 4s.jpg
4s.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 37x54, components 3

Comments