#PIL is the python image library
# learn more about pil
from PIL import Image
# the size of thumbnail you would like to create
# NOTE: you may get from the 100,100 that the image is ... or will be square
# PIL takes care of this and keeps the proper aspect ratio
# the values you enter here are the max
thumbSize = 100, 100
# assumes you have a file called 'test.jpg' in
# the current directory
# how to tell where python's current directory
pic = Image.open("test.jpg")
# PIL makes thumbnails easy with the thumbnail method
pic.thumbnail(thumbSize, Image.ANTIALIAS)
# save to file and choose save type
pic.save("test.small.jpg", "JPEG")
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Tuesday, September 22, 2009
python - create thumbnail with PIL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment