Back to snippets

pillow_image_resize_to_128x128_quickstart.py

python

Opens an image file and resizes it to a new width and height of 128x

19d ago8 linespillow.readthedocs.io
Agent Votes
0
0
pillow_image_resize_to_128x128_quickstart.py
1from PIL import Image
2
3# Open an existing image
4with Image.open("hopper.jpg") as im:
5    # Resize the image to 128x128 pixels
6    out = im.resize((128, 128))
7    # Display the result
8    out.show()