Skip to content
Related Articles

Related Articles

Improve Article
Wand text() function in Python
  • Last Updated : 10 May, 2020

Text can also be added using wand.drawing object. text() function is used to add text in the Drawing object. It takes x and y coordinates and string that we wan to write on (x, y) position.

Syntax :

wand.drawing.text(x, y, body)

Parameters :

ParameterInput TypeDescription
xnumbers.Integralthe baseline where to start writing text.
ynumbers.Integralthe left offset where to start writing a text.
bodybasestringthe body string to write.

Example #1:




# Import different modules of wand
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
import math
   
with Drawing() as draw:
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
  
        draw.font = 'wandtests/assets/League_Gothic.otf'
        draw.font_size = 10
        draw.text(image.width / 2, image.height / 2, 'GeeksForGeeks')
        draw(image)
        image.save(filename = "text.png")

Output:



Example #2:




# Import different modules of wand
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
import math
   
with Drawing() as draw:
    with Image(filename = "gog.png") as image:
        draw.font = 'wandtests / assets / League_Gothic.otf'
        draw.font_size = 10
        draw.text(image.width / 2, image.height / 2, 'GeeksForGeeks')
        draw(image)
        image.save(filename = "text.png")

Output :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :