PIL palette problem on PIL-1.1.2/Python-2.1/Solaris 2.8

plakal at nospam-cs.wisc.edu plakal at nospam-cs.wisc.edu
Tue Jul 10 18:37:03 EDT 2001


[I posted this to image-sig but I haven't
got responses yet and I'm in a bit of a hurry]

I'm trying to use PIL to draw a line
graph on a pre-existing GIF template file.

However, for some reason, no matter
what palette index I specify as
the ink, the lines I draw are all white
(which happens to be the first color
in the palette).

Can anyone spot what I'm doing wrong?
Code is at the end of the message.

This is with PIL-1.1.2, Python 2.1,
Solaris 2.8. Weirdly enough, the same
code works fine on Linux (with Python 2.0
and PIL-1.1.2).

Also, I tried the example code on
creating paletted images from scratch
and all I get is a black rectangle,
none of the shapes specified in the
code are drawn.


PS: Remove nospam- from my email address to respond by mail.

import Image, ImageDraw

image = Image.open( "graph_template.gif" )  # -- 500x600 GIF, 67-color palette

draw = ImageDraw.Draw( image )
draw.setink(1)   # -- Orange-ish
draw.line( [(52,550),(220,40)] )
draw.setink(2)   # -- another shade of orange
draw.line( [(220,40),(300,550)] )
draw.ellipse( (52,40,300,550) )

image.save( "graph.gif" )

More information about the Python-list mailing list