[Tutor] PIL's palette

Kent Johnson kent37 at tds.net
Thu Jul 14 20:22:11 CEST 2005

D. Hartley wrote:
> Hello, everyone!
> I am trying to figure out what a palette actually is, how it works,
> and what PIL's "putpalette()" does with a given data set (it has to be
> a string, I believe).  PIL's documentation says very close to nothing
> at all, and googling it has given me several other examples of doing
> what I already know how to do, but without explaining why or what it's
> actually doing (i.e., making it transferrable to other, different
> situations).  

You need to learn about "indexed color", which is a common way to represent color images. Each pixel represents an index into a color palette. The palette stores the actual RGB values for the color. By changing the palette you can dramatically change the image.

Google "indexed color" for more info. These links have pretty good explanations:


More information about the Tutor mailing list