Skip to content

Instantly share code, notes, and snippets.

@terrillo
Last active March 15, 2020 06:16
Show Gist options
  • Save terrillo/5152a55eec7f06af430daafe0a30c846 to your computer and use it in GitHub Desktop.
Save terrillo/5152a55eec7f06af430daafe0a30c846 to your computer and use it in GitHub Desktop.
resize-image-and-get-hex-color--resize
from resizeimage import resizeimage
from PIL import Image
image_path = './dog.jpeg'
new_max_width = 1800
new_filename = './dog-1800.jpeg'
with open(image_path, 'r+b') as f:
with Image.open(f) as image:
# Resize
smaller_image = resizeimage.resize_width(image, new_max_width)
smaller_image.save(new_filename, image.format)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment