Last active
August 19, 2019 03:28
-
-
Save satiridev/0a11c7b692f97ff08ae5038bebca8fa1 to your computer and use it in GitHub Desktop.
create written image using truetype font in python
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
# from https://code-maven.com/create-images-with-python-pil-pillow | |
from PIL import Image, ImageDraw, ImageFont | |
# mode L for grayscale | |
img = Image.new('RGB', (100, 30), color = (73, 109, 137)) | |
# font path | |
fnt = ImageFont.truetype('/Library/Fonts/Arial.ttf', 15) | |
d = ImageDraw.Draw(img) | |
d.text((10,10), "Hello world", font=fnt, fill=(255, 255, 0)) | |
img.save('pil_text_font.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment