from PIL import Image img = Image.open('example.jpg') img.show()
from PIL import Image img = Image.open('example.jpg') new_img = img.resize((500, 500)) new_img.show()
from PIL import Image img = Image.open('example.jpg') img.thumbnail((200, 200)) img.save('thumbnail.jpg')This example reads an image file named 'example.jpg' and creates a thumbnail of the image with a size of 200x200 pixels using the `thumbnail()` method. The thumbnail is then saved to a file named 'thumbnail.jpg' using the `save()` method. Package library: PIL (Python Imaging Library) or its fork, Pillow.