[Image-SIG] How to specify the color of a text
Guy K. Kloss
G.Kloss at massey.ac.nz
Wed Apr 30 23:14:48 CEST 2008
On Tue, 29 Apr 2008 4:09:05 pm cafeeee wrote:
> >>> color = "blue"
> >>> draw.text((10, 10), "HELLO", fill=color, font=font)
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "D:\Program Files\Python25\Lib\site-packages\PIL\ImageDraw.py", line
> 256, in text ink, fill = self._getink(fill)
> File "D:\Program Files\Python25\Lib\site-packages\PIL\ImageDraw.py", line
> 145, in _getink ink = self.palette.getcolor(ink)
> File "D:\Program Files\Python25\Lib\site-packages\PIL\ImagePalette.py",
> line 62, in getcolor self.palette = map(int, self.palette)
> ValueError: invalid literal for int() with base 10: ''
Hmmm, the docmentation is here:
http://www.pythonware.com/library/pil/handbook/imagedraw.htm
It's a bit ambiguous, as on the top it states that colours can also use HTML
like names (as you did), but further down it says for the options this:
"fill: integer or tuple"
So, is it possible that your version of PIL is < 1.1.4, or that your image
type is incompatible with (that type of) colours? Just give the other options
a shot as mentioned in the section "Colours" and/or "Colour Names".
HTH,
Guy
--
Guy K. Kloss
Institute of Information and Mathematical Sciences
Te Kura Putaiao o Mohiohio me Pangarau
Room 2.63, Quad Block A Building
Massey University, Auckland, Albany
Private Bag 102 904, North Shore Mail Centre
voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181
eMail: G.Kloss at massey.ac.nz http://www.massey.ac.nz/~gkloss/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/image-sig/attachments/20080501/0b8a383c/attachment.pgp>
More information about the Image-SIG
mailing list