Harry
Harry

Reputation: 13329

PIL polygon fill issue

I'm using PIL==1.1.7

I'm trying to fill a polygon with a color like this:

def save(self):
    try:
        image = Map.objects.all()[0].image
        im = Image.open(image.path)
        draw = ImageDraw.Draw(im)
        draw.polygon(((685,255),(714,361),(698,389),(610,411),(575,285)), fill=(255,255,255))

        del draw 
        format = 'png'
        im.save(image.path, format)
    except Exception, e:
        print e
        pass

But I get the exception:

invalid literal for int() with base 10: '\x8f'

It works like this:

draw.polygon(((685,255),(714,361),(698,389),(610,411),(575,285)), fill=128)

What does this error mean?

I'm trying to draw transparent polygons onto my image.

Upvotes: 0

Views: 1961

Answers (1)

Gerrat
Gerrat

Reputation: 29690

You may have run into a bug in PIL: bug report.

If you posted the complete traceback, I could tell better. If it is this bug, then it looks like changing line 62 in ImagePallet.py with this:

self.palette = map(ord, self.palette)

would fix it (basically replacing int with ord on that line).

Upvotes: 1

Related Questions