2017-09-04 27 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

回答