2017-09-04 49 views
1

我使用Pillow卡住了一个小的(我猜)错误。我试图用变量设置我的文本的颜色,但得到一个ValueError:未知的颜色说明符:''232,43,123,255''在试用时。 这里是我的代码:不能使用变量来定义枕头的颜色

header = Image.open("A.png") 
couleur_Ellipse = "rose" 
draw = ImageDraw.Draw(header) 
point = (int(header.width * 0.780), int(header.height * 0.68)) 
header.paste(ellipse, point, ellipse) 
colortext = '"232,43,123,255"' 
pointtext1 = (int(header.width * 0.845), int(header.height * 0.75)) 
pointtext2 = (int(header.width * 0.798), int(header.height * 0.79)) 
draw.text(pointtext1, "this is some text", font=ImageFont.truetype("C:\Windows\Fonts\Arial.ttf", 14), fill=colortext) 
draw.text(pointtext2, "some other text", font=ImageFont.truetype("C:\Windows\Fonts\\arialbd.ttf", 55), fill=colortext) 
header.save('Images/header ' + couleur_Ellipse + '.png') 

任何见解?我不明白为什么它不工作

+0

http://pillow.readthedocs.io/en/3.1.x/reference/ImageColor.html 这似乎是你需要提供彩色功能,而不是只是一串价值观。我还假定您正在使用等于或大于1.1.4的PIL版本,以便您可以提供Alpha值? 尝试不带alpha:colortext =“rgb(232,43,123)” –

+0

它的工作原理!非常感谢。我不是母语的人,所以文档总是有点难以阅读。谢谢 ! – CommYov

回答