Learn Before
Concept
ImageFont Class (Pillow)
The ImageFont class allows for ImageDraw objects to incorporate font text. ImageFont supports both bitmap fonts and OpenType/TrueType fonts. The former uses Pillow's own formats, .pil and .pbm, and the latter uses the .otf and .ttf font file formats. Use ImageFont.load() to load a bitmap font and ImageFont.truetype() for a OpenType/TrueType font. ImageDraw's font() function can then be used to draw the text into an ImageDraw object.
font = ImageFont.truetype(fontfile) d = ImageDraw.Draw(image) d.text(position, string, color, font)
font = ImageFont.truetype(fontfile, size) d = ImageDraw.Draw(image) d.text(position, string, color, font)
0
1
Updated 2021-08-23
Tags
Python Programming Language
Data Science