Skip to content

Instantly share code, notes, and snippets.

@alexfriant
Last active March 7, 2016 17:11
Show Gist options
  • Save alexfriant/8f65bdd7e3932b683db9 to your computer and use it in GitHub Desktop.
Save alexfriant/8f65bdd7e3932b683db9 to your computer and use it in GitHub Desktop.
Modify image sizes for all images in a folder
from PIL import Image
import glob, os
size = 800, 600
for infile in glob.glob("c:/myphotos/*.jpg"):
file, ext = os.path.splitext(infile)
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(file + ".jpg", "JPEG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment