« Return to Thread: Poor Image Quality When Resizing a GIF

Re: Poor Image Quality When Resizing a GIF

by Fredrik Lundh :: Rate this Message:

Reply to Author | View in Thread

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@...
http://mail.python.org/mailman/listinfo/image-sig

 « Return to Thread: Poor Image Quality When Resizing a GIF