[Image-SIG] Re: Problems with new image creation

Keith Dart kdart@cisco.com
Fri, 5 Feb 1999 12:28:59 -0800 (PST)


Thanks a bunch for the helpful suggestion. That worked. Note that my
original attempt is exactly what is shown in the manual...

BTW, are you aware of any high-level graph/plotting functions/classes that
use PIL? I found one that uses the GD library, but not PIL.

Thanks again,
Keith Dart

On Fri, 5 Feb 1999, Fredrik Lundh wrote:

> >Hello, I'm trying to use the 1.0b1 PIL package to generate some GIF files
> >from scratch. This is for a web application. I'm trying to generate a new
> >.gif file where none existed before, with a color palette. However, I get
> >errors when trying to apply a new palette (it seems to default to
> >greyscale).  Here's the script:
> >
> >------------------------
> >#!/usr/bin/python
> >
> >import sys, os
> >import Image
> >import ImageDraw, ImagePalette
> >
> >im = Image.new('P', (640,480), 255)
> 
> ...
> 
> try setting the palette using "putpalette"
> instead (I doubt this is documented):
> 
> palette = []
> for i in range(256):
>     palette = palette + [i, i, i]
> im.putpalette(palette)




-- --------------------------------------------------------------------------
Keith Dart, Devtest Engineer, Linux Bigot        <mailto:kdart@cisco.com>
Cisco Systems                                    phone: +1.408.527.1391
Network to User Business Unit                    pager: +1.800.365.4578
internal web page: <http://kdart-pc.cisco.com/>
external web page: <http://www.employees.org/~kdart/>
=============================================================================