[PYTHON IMAGE-SIG] PIL and palettes and drawing.

Anthony Baxter arb@connect.com.au
Tue, 17 Dec 1996 18:42:34 +1100


Does anyone have any nice examples of how to do drawing using PIL and
palettes?

How do I initialise a colour palette? In particular, I'm trying to use
ImageDraw, with a new image object, and I need to know how to drive the
constructor &c for the palette.

im=Image.new("P",(400,400))
im.palette=ImagePalette.ImagePalette("RGB")

when I try to do stuff with this image, I get told 'no palette' or similar.

now I want to set colour 0 to #000000, colour 1 to #ff0000, &c. What's
the magic required?

(On a possibly related note - when I load an existing GIF file, I find it's
palette is of type 'tuple', not of type 'ImagePalette'. I wonder if this
is what I should be doing?)

ta,
Anthony

=================
IMAGE-SIG - SIG on Image Processing with Python

send messages to: image-sig@python.org
administrivia to: image-sig-request@python.org
=================