[IMAGE-SIG] Palettes and current version

Fredrik Lundh fredrik@pythonware.com
Tue, 4 Nov 1997 17:22:03 +0100

David wrote:
>I'm a bit of a newbie to imaging, and have a couple of questions
>regarding PIL.  First off, I'm curious what the current version
>for Unix is.  0.2b4 is the version I found on the Image-sig
>page, but that version seems quite out dated (February?), and
>I've seen mention in the Image-sig archive of versions .3b1 and

There's a 0.3a1 source kit available from my starship cabin:


the 0.3a2 code base is available only in a binary for Win32
(at www.pythonware.com).

>However, when I attempted to draw rectangles of various colors onto
>this image, I got an error:
>    self.im.draw_rectangle(xy, self.ink, self.fill)
>ValueError: PIL: images do not match

The 0.2 lib only supports 8-bit targets for drawing operations;
this has been fixed in the current code base.

>After looking into the documentation, I realized that I needed
>to define my image with a palette to use the rectangle method.
>I redefined my image using 'P' instead of 'RGB', and then attempted
>to create image.palette using ImagePalette.ImagePalette('RGB').

The palette code is pretty much broken in all the available source
kits; in practice, cleaning up this mess is all that remains before we
can release 0.3 final (this includes RGB->P conversion, colour allocation
stuff, etc).  Hopefully, we'll get around to do that before it's time to
release PIL Pro 1.0 (aka 'zircon')...

Anthony Baxter posted an improved ImagePalette module to this
list quite a while ago that may help in your case; you should be
able to find that via


(in worst case, grab the complete archive from www.python.org).

Cheers /F

IMAGE-SIG - SIG on Image Processing with Python

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