how to add text on image and adjust on the image by knowing the image end?
You can see below the text is big so only half of the quote is printed on it.
I want to get control over the printing area. Ex. Suppose the text is big then the text has to be continued from the new line.
I'm using PILLOW for this, but struggling with logic for this as there are no methods handy available for it.
def pic_mart(template = "image/black white dot image template.jpg",new_image_name="cropped_picture.jpg",text_content="Only one thing is ever guaranteed, that is that you will definitely not achieve the goal if you don't take the shot."):
try:
#Image open
# img = Image.open(template)
img = Image.new('RGB', (1280,720), (100, 100, 200)) #x,y
img.save("image.png", "PNG")
print(img)
width, height = img.size
print("H-W",height,width)
d1 = ImageDraw.Draw(img)
myFont = ImageFont.truetype(r'C:\Users\System-Pc\Desktop\arial.ttf', 50)
d1.text((0, 0), text_content, font=myFont, fill =(125, 200, 200))
img.show()
except Exception as e:
print("Oops!", "occurred", e.__class__)
pic_mart()
If you have some idea about autoformatting, such as if text goes out from particular selected are then size should be reduced. We have text function in PIL which directly paste the text on image but no control over the character by character level to map with other background. How can we do that?
Thanks in advance to share you knowledge. Grateful for this community.