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

Andy McCurdy andy at andymccurdy.com
Wed Jan 9 22:59:41 CET 2008


Your suggestion didn't seem to fix the problem.  It will probably be
helpful for you to take a look at what I'm seeing.

Here's the original .gif file I'm testing with:
http://www.andymccurdy.com/original.gif

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

Here's the image resized again with your suggestion of converting to
"P" mode and setting the dithering prior to saving:
http://www.andymccurdy.com/resized_2.gif

You'll see both of the resized images are pretty poor quality.

On Jan 9, 2008 1:13 PM, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Andy McCurdy wrote:
>
> > Fredrik, thanks for the reply.  I am in fact converting to "RGB"
> > first... at least I think so.  Here's the code I'm using that produces
> > bad results:
> >
> > from PIL import Image
> >
> > # io is a file handle
> > pil_image = Image.open(io)
> >
> > # convert to rgb
> > pil_image = pil_image.convert('RGB')
> >
> > # new_width/new_height are calculated to retain the
> > # current height/width proportions
> > new_size = (new_width, new_height)
> >
> > #resize the image
> > pil_image = pil_image.resize(new_size, Image.ANTIALIAS)
> >
> > # save the image back to disk
> > pil_image.save(io, 'GIF')
>
> is the grain you're talking about perhaps floyd-steinberg dithering?  do
> your images look better if you insert
>
>     pil_image = pil_image.convert("P", dither=Image.NONE)
>
> before you save the image?
>
>
> </F>
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>


More information about the Image-SIG mailing list