Skip to content

Instantly share code, notes, and snippets.

@CrowderSoup
Last active August 29, 2015 14:11
Embed
What would you like to do?
Just a quick example of how to resize an INCREDIBLY large image.
from PIL import Image
# 8 Inches
basewidth = 768
# This is the size of the image I was working with... this line will supress warnings about the image being too big
Image.MAX_IMAGE_PIXELS = 556631040
# Open the image
img = Image.open("original.png")
# Calculate the width % and height size based on the fixed width
# To do fixed height you would simply flip things around
wpercent = (basewidth / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
# Resize the image using anti-aliasing
img = img.resize((basewidth, hsize), Image.ANTIALIAS)
# Save the image
img.save("/Users/acrowder/Desktop/resized.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment