How to optimize images in Python

This can be done in many ways. We will do through the module pyllow


Install inside the virtual environment:


from PIL import Image
from datetime import datetime

timestamp =

path = ‘public / build / screenshots’
img = f‘{path} /screenshot.png’

im =
im = im.convert(“RGB”)
im = im.resize((1200, 750), Image.ANTIALIAS)“{path} / {timestamp} .jpg”, optimize= True, quality=75)

Can be combined with Python screenshots.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *