Created
March 12, 2020 10:57
-
-
Save namieluss/e078bed628e3b5741ca6d8af8a446941 to your computer and use it in GitHub Desktop.
Generate a Thumbnail from an Image using Python Pillow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
# open image | |
img = Image.open("test_image.jpg") | |
# set the maximum width and height for the thumbnail | |
max_thumbnail_size = (200, 200) | |
# applying size for thumbnail | |
img.thumbnail(max_thumbnail_size) | |
# creating thumbnail | |
img.save("test_image_thumb.jpg") | |
# show image in preview | |
img.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment