[Image-SIG] Poor Image Quality When Resizing a GIF

Andy McCurdy andy at andymccurdy.com
Thu Jan 10 00:08:50 CET 2008


Hey Douglas,

I interpreted your response as a setting to change to make this
specific image resize better.  I'm using PIL to resize images that
users upload to my website.  Since I don't have control over the
media, I need generic settings that will be good for all users.  What
settings would you suggest to be best for all images, not just the
example I provided?

On Jan 9, 2008 2:57 PM, douglas bagnall <douglas at paradise.net.nz> wrote:
> hi Andy
>
> > Here's the resized gif with the original code I pasted.  You'll see a
> > bunch of 'dots' throughout the image:
> > http://www.andymccurdy.com/resized_1.gif
>
> PIL uses the so-called "web palette" by default.  Your image uses
> #fdfdfd for white, but the web palette uses #ffffff. So it dithers to
> approximate #fdfdfd.  You probably really want the background to be
> pure #ffffff white, because printers etc will also dither, but the
> more immediate problem is the web palette. Try this:
>
> pil_image = pil_image.convert("P", palette=Image.ADAPTIVE)
>
> or
>
> pil_image = pil_image.convert("P", dither=Image.NONE, palette=Image.ADAPTIVE)
>
> These options are not well documented, but you can find them in the
> PIL/Image.py source.
>
> douglas
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>


More information about the Image-SIG mailing list