Skip to content

Instantly share code, notes, and snippets.

@zjor
Created April 3, 2013 09:22
Show Gist options
  • Save zjor/5299702 to your computer and use it in GitHub Desktop.
Save zjor/5299702 to your computer and use it in GitHub Desktop.
Script for resizing images
# make sure that you have libjpeg and PIL installed
import re
import os, sys
import Image
size = 60, 60 # max_width, max_height
files = [f for f in os.listdir('.') if re.match(r'view[\d]{3}_large', f)]
for infile in files:
base_name = re.search(r'(view[\d]{3})', infile).group(1)
outfile = base_name + "_thumb.jpg"
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(outfile, "JPEG")
print "%s -> %s" % (infile, outfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment