Alter the compression-ratio on JPEG-images using PIL & Resizing/scaling images properly

David Eppstein eppstein at ics.uci.edu
Wed Jan 23 11:22:47 EST 2002


In article <osA38.19$ti7.169739776 at news.telia.no>,
 "Thomas Weholt" <thomas at gatsoft.no> wrote:

> And what is the proper way to resize or scale an image? When I use
> img.thumbnail() the result is very jaggy around the edges. Any hints? I want
> to create thumbnails and a resized version with specific max values for
> height/width of the original image.

For modest downsizing without jaggies, I use:

filter(ImageFilter.SMOOTH)
resize(..., Image.BICUBIC)

The smoothing step should really be a carefully tuned box filter -- the 
effect you're trying to achieve is to make each downsized pixel be the 
average over a small square of (the bicubic interpolation of) the original 
image, rather than just a point sample from that image.  But I didn't see 
any box filters in PIL's docs...
-- 
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