[Image-SIG] Resizing Tif's to smaller gifs adds pixels

Samuel Mullen smullen at uclick.com
Tue Oct 21 20:22:25 CEST 2008

I'm not entirely sure how this group works: if there is a page I'm supposed
to follow up on or if I should expect an email in reply.  Anyway, here's my

I'm very new to Python and PIL, I know how to do this stuff in perl and
ImageMagick, but I'm having issues with Python and PIL.

I need to scale a TIFF image from 1925x588 px to a GIF of 600xnnn px.

I've tried the following code, but it leads to a lot of extra odd colored
pixels being inserted into the resulting image.

img = "tmp/tmsho20080901.tif"
im = Image.open("tmp/tmsho20080901.tif")
w, h = im.size

im.thumbnail((600, h * 600 / w), Image.ANTIALIAS)

newimg = im.resize((600, int(h * (600.0 / w))), Image.ANTIALIAS)

Using ImageMagick's convert I would do this...

convert -colors 256 -resize 600 -colorspace RGB -black-threshold 100
-contrast -intent Perceptual tmp/tmsho20080901.tif tmsho20080901.gif

I think it may have something to do with the palette or the number of colors
alotted for the resulting image, but I'm really not a graphics guy.

Any help on this would be appreciated.

Samuel Mullen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20081021/94848435/attachment.htm>

More information about the Image-SIG mailing list