Re-sizing images in Python?

David Eppstein eppstein at ics.uci.edu
Sat Jul 14 20:35:39 EDT 2001


In article <q6547.41446$B56.8781902 at news2-win.server.ntlworld.com>,
 "Darren Watson" <Darren.Watson3 at ntlworld.com> wrote:

> I would like to write a script that can process all the files in a directory
> and resize the images to a specified size (passed in as an argument).
> However, I am not sure if this is a task that Python 2.1 can perform or if
> it is, which library to use.

This is not difficult to do using the Python Imaging Library.
If you are doing significant size reductions, you probably want to smooth 
the image a little first to avoid pixelization problems.

Contact me by email if you want me to send you some code I wrote to do this 
as part of a web photo gallery generation applet (see 
http://www.ics.uci.edu/~eppstein/pix/ for results). My program uses 
Mac-specific user interface code so would require significant modification 
to run on your PC, but the image resizing stuff should be pretty portable.
-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list