Skip to content

Instantly share code, notes, and snippets.

@rikwatson
Created April 1, 2019 12:45
Show Gist options
  • Save rikwatson/2ad4bbe16a8d2e9000976b8767753a8d to your computer and use it in GitHub Desktop.
Save rikwatson/2ad4bbe16a8d2e9000976b8767753a8d to your computer and use it in GitHub Desktop.
Python Image / Thumbnail Resizer
import os, sys
import Image
size = 128, 128
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".thumbnail"
if infile != outfile:
try:
im = Image.open(infile)
im.thumbnail(size)
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for", infile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment