'TypeError: color must be int or single-element tuple

Here is the error encoutered:

TypeError: color must be int or single-element tuple

Here is the code I am running:

from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont, ImageOps
label1 = "VIKRAM"
font = ImageFont.truetype('D:/vikram/pythonProject/fonts/BalloonCraft-9YBK7.ttf', 800)
line_height = sum(font.getmetrics())
fontimage1 = Image.new('L', (font.getsize(label1)[0], line_height))
ImageDraw.Draw(fontimage1).text((0,0),str(label1),stroke_width=10, stroke_fill=(0, 0, 0), fill=255, font=font)
fontimage1 = fontimage1.rotate(90, resample=Image.NEAREST, expand=True)
orig = Image.open('F:/desktop/Kitty/PSI Hello Kitty Theme Personalized Door Poster-1.png')
orig.paste((135, 255, 135), box=(2200, 1500), mask=fontimage1)
orig.show()

If you have any idea how to fix this, please I would be very grateful. Thanks in advance.



Solution 1:[1]

I belive as you put the 'L' in Image.new your image will be gray scale, therefore you can't specify a RGB tuple for stroke_fill because you only have black shades. As specified in the error message you have to use a int or a single tuple.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1