Create Image Thumbnails (Python)
1 2 # experiments with the Python Image Library (PIL) 3 4 # free from: http://www.pythonware.com/products/pil/index.htm 5 6 # create 128x128 (max size) thumbnails of all JPEG images in the working folder 7 8 # Python23 tested vegaseat 25feb2005 9 10 11 import glob 12 import Image 13 14 # get all the jpg files from the current folder 15 16 for infile in glob.glob("*.jpg"): 17 im = Image.open(infile) 18 # convert to thumbnail image 19 20 im.thumbnail((128, 128), Image.ANTIALIAS) 21 # don't save if thumbnail already exists 22 23 if infile[0:2] != "T_": 24 # prefix thumbnail file with T_ 25 26 im.save("T_" + infile, "JPEG")