Skip to content

Instantly share code, notes, and snippets.

@JasonCrowe
Created August 17, 2018 02:25
Show Gist options
  • Save JasonCrowe/9cf034d3c5f32e347e7d7a3680739748 to your computer and use it in GitHub Desktop.
Save JasonCrowe/9cf034d3c5f32e347e7d7a3680739748 to your computer and use it in GitHub Desktop.
make image into thumbnail
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, Image.ANTIALIAS)
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for '%s'" % infile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment