Answer the question
In order to leave comments, you need to log in
How can this code snippet be improved?
Below is a code snippet that draws text on an image.
Is there any way to improve this code snippet? In terms of further maintenance / clean code?
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
class drawer():
def __init__(self,image):
self.image = Image.open(image)
self.draw = ImageDraw.Draw(self.image)
self.font = ImageFont.truetype("18991.ttf", 16)
def draw(self,text,x,y):
self.draw.text((x,y),text,(255,255,255),font=self.font)
def save(self,path):
self.image.save(path)
if __name__ == '__main__':
img = drawer("sample.jpg")
img.draw("15:51",50,1230)
img.save("Ex.jpg")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question