Transform a png in a thumbnail

If you want to transform a png in a smaller image the way it feels good, you can use the following code. Remember to add the PIL module writing in the cmd or powershell (in Windows) pip install pillow. In this example we transform the file “euro1.png” that is located in the same dir where this code will be saved as thumb.py (for example) into a euro1c.png file of smaller dimensions (100×100).

from PIL import Image
import os

im = Image.open('euro1.png')
im.thumbnail((100,100), Image.ANTIALIAS)
im.save('euro1c.png', "PNG")
os.system('euro1c.png')

Utilities