Skip to content

Instantly share code, notes, and snippets.

@namieluss
Created March 12, 2020 10:57
Show Gist options
  • Save namieluss/e078bed628e3b5741ca6d8af8a446941 to your computer and use it in GitHub Desktop.
Save namieluss/e078bed628e3b5741ca6d8af8a446941 to your computer and use it in GitHub Desktop.
Generate a Thumbnail from an Image using Python Pillow
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