[Image-SIG] Poor Image Quality When Resizing a GIF
Fredrik Lundh
fredrik at pythonware.com
Wed Jan 9 22:13:19 CET 2008
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>
More information about the Image-SIG
mailing list