[Image-SIG] Palette problem with ImageGrab

Alfred Milgrom fredm at smartypantsco.com
Tue Nov 11 21:04:15 EST 2003


Hi:

I am having a bit of trouble with the palette of images created using 
ImageGrab, and would be grateful if anyone can help.

After using ImageGrab and setting the mode to 'P', the palette returned by 
im.palette is always the default (gradated) palette, rather than the 
palette of actual colours in the grabbed image.

Everything else is fine, and I know that the program has the correct 
palette stored somewhere because when I save the image it saves it to file 
with the right colours.

I have tried to flush out the correct palette by asking for a histogram, or 
by using im.palette.tostring(), but this does not work.

In order for me to work with the correct palette I am having to save the 
grabbed image to file and then reload the saved image.
This is obviously not the optimum way of doing things.

Thanks in anticipation,
Fred Milgrom





More information about the Image-SIG mailing list