Scaling pictures
Ravi Teja
webraviteja at gmail.com
Thu Dec 28 08:32:35 EST 2006
Kajsa Anka wrote:
> I would like some advice, I'm going to build a small app that will, among
> other things, scale images so that they can be published on a web site. I've
> never done any image processing in python before so I would like to ask what
> is the best way of doing this, I will not do anything else than scaling the
> images.
>
> I found the Python Imaging Library but before I dive into that I would like
> to know if there is a better way of doing this.
Yes. Python Imaging Library (PIL) is the preferred Python way to do
this. The example is right in the documentation.
http://www.pythonware.com/library/pil/handbook/image.htm
from PIL import Image
import glob, os
size = 128, 128
for infile in glob.glob("*.jpg"):
file, ext = os.path.splitext(infile)
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(file + ".thumbnail", "JPEG")
More information about the Python-list
mailing list