[Image-SIG] Image quality when resizing

Fredrik Lundh fredrik@effbot.org
Wed, 24 Jan 2001 16:21:59 +0100


Chuck wrote:

> >You could try applying a slight blur before conversion to get nicer
> >looking pictures even for NEAREST but you still need to do it in RGB space.
> 
> Even with other packages you often need to tweak the resulting image
> (never ried tweaking the original), but I'd prefer to have a good resize()
> first rather than having to concoct a recipe for it.

the correct approach would be to apply a suitable
lowpass filter, and then use NEAREST on the result.

unfortunately, PIL doesn't support that (yet).

here's a brute-force method that might give you
somewhat better results:

    # pseudocode
    im = Image.open("...")
    im.draft("RGB", target size) # optional
    while im.size > target size * 2:
        im = im.resize(im.size / 2, Image.BILINEAR)
    thumbnail = im.resize(target size, Image.BILINEAR)

(sorry, no time to turn that into a real python script,
nor to try it on your samples.  maybe later this week)

Cheers /F