[Image-SIG] PIL image resizing quality seems a little rough, any workarounds?

Jeff Kowalczyk jtk@yahoo.com
Fri, 12 Jul 2002 20:13:25 -0400


I'm using Zope's Photo product, which uses PIL or imagemagik to generate
thumbnails for an uploaded image. I like the PIL API, from what I've seen of
it so far. I'm using PIL 1.1.3 on Win32 with Zope-Photo, and the resized
images don't look nearly as good as ones done in a program like Paint Shop
Pro. They're quite jagged.

Is this just an area PIL isn't strong in yet, or are there tricks to improve
the quality? Speed isn't an issue for me, this is a one-time resizing
operation at upload time. Is improved resizing quality available in the
development version?

Here's the function in Photo that does the work. I use quality=100.

    def _resize(self, display, width, height, engine='ImageMagick',
quality=75):
        """Resize and resample photo."""
        origimg = self._original
        newimg = StringIO()
        if engine == 'PIL':  # Use PIL
            img = PIL.Image.open(origimg._PILdata())
            fmt = img.format
            img = img.resize((width, height))
            img.save(newimg, fmt, quality=quality)
        elif engine == 'ImageMagick':  # Use ImageMagick
            ( ... )
        newimg.seek(0)
        return newimg

Thanks!