X
X
xxxfdd2020-05-16 23:36:05
Python
xxxfdd, 2020-05-16 23:36:05

How to display a watermark for example black?

How can I make a water snack not white but black here is the source code

from PIL import Image, ImageDraw, ImageFont
import sys

try:
    tatras = Image.open("test.jpg")
except:
    print("Unable to load image")
    sys.exit(1)

idraw = ImageDraw.Draw(tatras)
text = 'Привет'
font = ImageFont.truetype("arial.ttf", size=30)

idraw.text((10, 10), text, font=font)

tatras.save('tatras_watermarked.png')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Eremin, 2020-05-17
@xxxfdd

idraw.text((10, 10), text, font=font, fill=(0,0,0,255))

The parameter fillis a tuple of four numbers, the color is encoded according to the RGBA scheme (that is, transparency can be adjusted).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question