Create JPEG thumbnails
From Julian Yap
[edit]
Create JPEG Thumbnails
From here:
import os, sys
import Image
#size = 128, 128
# ImageShack uses:
size = (152, 167)
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", infile
Notes:
- It would be handy to grab the size and file size of the image to later throw into ALT tags.
- This produces the best quality Anti-aliased thumbnails.
