Created
August 2, 2011 08:04
-
-
Save hectorddmx/1119784 to your computer and use it in GitHub Desktop.
How to generate thumbnails from existing jpg image files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import Image | |
# HDB: set preferences here | |
source_extension = "*.jpg" | |
size = 110, 80 | |
prefix = "t" | |
target_extension = "JPEG" | |
# get all the jpg files from the current folder | |
for infile in glob.glob(source_extension): | |
im = Image.open(infile) | |
# don't save if thumbnail already exists | |
if infile[0:2] != prefix: | |
# convert to thumbnail image | |
im.thumbnail(size, Image.ANTIALIAS) | |
# prefix thumbnail file with T_ | |
im.save(prefix + infile, target_extension) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment