Create images thumbnails with Python
import glob
import Image
dir="/home/username/Pictures/"
 
for infile in glob.glob(dir+"*.jpg"):
	imgfile=infile[(infile.rfind("/")+1):]
	if infile[0:2] == "thumb_":
		continue
	try:
		img = Image.open(infile)
		img.thumbnail((128, 128), Image.ANTIALIAS)
		img.save(dir + "thumb_" + imgfile, "JPEG")
	except IOError:
		img=None
%d bloggers like this: