-
-
Save szepnapot/9fcdaace3937b0fe9e4fee5eb3c19448 to your computer and use it in GitHub Desktop.
Write text to image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
from PIL import ImageFont | |
from PIL import Image | |
from PIL import ImageDraw | |
workdir = os.path.dirname(os.path.abspath(__file__)) | |
text = ' '.join(sys.argv[1:]) | |
print(text) | |
font = ImageFont.truetype(workdir + "Roboto-Medium.ttf",25) | |
img = Image.new("RGBA", (400,400),(120,20,20)) | |
draw = ImageDraw.Draw(img) | |
draw.text((50, 50),text,(255,255,0),font=font) | |
draw.chord((100, 75, 125, 100), 0, 360, fill='green') | |
draw.chord((75, 100, 100, 125), 0, 360, fill='blue') | |
draw.chord((125, 125, 150, 150), 0, 360, fill='yellow') | |
draw = ImageDraw.Draw(img) | |
img.save("test.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment