...Anyway let's just slip off topic for a second here and imagine that you're in charge of some online art gallery/community where members can upload images and have them displayed for the world to see. As part of the site's design every image has a square thumbnail that links to the full-sized image.
We can think of this as a few steps:
Loading the image and passing it to our function.
Cropping our image so we end up with a square.
Resizing (100 x 100) and saving our thumbnail.
size = list(image.size)
image = image.crop((0, 0, size, size))
image = image.resize((100, 100), Image.ANTIALIAS)
if __name__ == '__main__':
image = Image.open('sample1.jpg')
image = thumb(image)
This really just defines a new user function named thumb() which we can then use to create our thumbnails! It starts by converting the images size to a list and sorting it in place so we have the smallest dimension at the beginning of the list (this value is then used while cropping our image). The next part then crops and resizes our image using the ANTIALIAS filter (better quality) before returning the new image....
this was taken from [www.devshed.com
] check it out if'n you get some spare time