[Tutor] quick PIL question
carroll at tjc.com
Fri Jun 3 00:39:16 CEST 2005
On Thu, 2 Jun 2005, D. Hartley wrote:
> What does it mean if my image mode is "P"? In the documentation, it
> says "typical values are '1', 'L', 'RGB', 'CMYK.'" (it's a gif, if
> that's important)
That's really weird. It does say that (in the description of im.mode,
where you'd expect it). But other parts of the doc refer to a "P" mode;
see the descriptions of im.convert; im.putpalette; and the BMP format
Seems to be some sort of "palette" format.
Hey! Look under "Concepts":
The mode of an image defines the type and depth of a pixel in the
image. The current release supports the following standard modes:
. . .
- P (8-bit pixels, mapped to any other mode using a colour palette)
. . .
The palette mode ("P") uses a colour palette to define the actual
colour for each pixel.
Not sure what that means, exactly, but it looks like im.palette will get
the palette of a a P-mode image, and im.putpalette will change it.
I'm not sure how to interpret the palette once you have it, though. The
description of the ImagePalette class is not too helpful.
More information about the Tutor