[Image-SIG] Saving multi-frame images with palette

skip at pobox.com skip at pobox.com
Wed Sep 6 04:19:11 CEST 2006

I'm new here, using PIL (1.1.5) to do some front-end image manipulation for
SpamBayes' nascent OCR capability.  One of the tricks the spammers use now
is multi-frame GIFs where most/all of the text is on some frame other than
the first one.  Here's an example:


I'm hoping to poke around a bit in the image using PIL to decide which frame
to analyze (in theory I could run OCR on all frames, but it's an expensive
enough operation already) and also to save the frame I select.

The above image presents a problem though.  Using this code:

    >>> img = Image.open("bogus-0.gif")
    >>> for frame in ImageSequence.Iterator(img):
    ...   frame.show()

the first frame is displayed using the image's palette.  The rest are
displayed in black-and-white.  I suspect there's something fishy about this
particular image.  I have another one that show()s just fine, and this one
displays properly in Firefox, so at some level it must be okay.

Any suggestions?


Skip Montanaro - skip at pobox.com - http://www.mojam.com/
"In China today, Bill Gates is Britney Spears.  In America today, Britney
Spears is Britney Spears - and that is our problem."  Thomas L. Friedman in
"The World is Flat"

More information about the Image-SIG mailing list