[Image-SIG] Convert Function and Palette Mode

Fredrik Lundh fredrik@pythonware.com
Tue, 20 Mar 2001 12:36:27 +0100


walter wrote:

> > Is there anyway to set a palette which is used
> > to convert an image to "PaletteMode" ?
>
> I don't think there is such a function or parameter,
> but Fredrik can probably tell us more.

it's all hidden on the C API level.  Bill Jansen recently posted patches
to make this available via the Python API:

    I've completed some work on extending PIL 1.1.1 to support raw Palm
    image quantization and output.  You can find a gzipped tar file
    containing a patch and a new ImagePlugin at
    ftp://ftp.parc.xerox.com/transient/janssen/PILpalm.tgz.

    The README in that file explains how to apply the support to a vanilla
    PIL 1.1.1 source distribution.

    The most interesting thing to you, I think, is the extension of the
    quantize method, via a new keyword, to support quantizing the colors
    of an image to a specified palette.  That palette is specified by
    passing an image containing the desired palette.  There were a number
    of ways to add this functionality; this seemed to be the approach that
    involved the minimal change to PIL.

my plan is to get (some variation of) Bill's patches into 1.1.2 (soonish).

Cheers /F