Mike C. Fletcher wrote: > The core function looks something like this: > > import Image # this is PIL > > def getThumbnail( filename, size = (32,32) ): > '''Get a thumbnail image of filename''' > image = Image.open(filename) > rx, ry = image.size[0]/float(size[0]), image.size[1]/float(size[1]) > if rx > ry: > resize = int(size[0]), int(round(image.size[1]*(1.0/rx), 0)) > else: > resize = int(round(image.size[0]*(1.0/ry), 0)), int(size[1]) > image = image.resize( resize, Image.BILINEAR )
footnote: if you're creating thumbnails from JPEG or PhotoCD images, using the "thumbnail" method can be a lot more efficient (unlike resize, it tweaks the codec so it doesn't have to load the entire full-sized image). footnote 2: Image.ANTIALIAS is slower, but tends to give a much better result than Image.BILINEAR, especiall for "noisy" images. </F> -- http://mail.python.org/mailman/listinfo/python-list