Wand text() function in Python (original) (raw)
Last Updated : 16 Mar, 2023
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 want to write on (x, y) position.
Syntax :
wand.drawing.text(x, y, body)
Parameters :
Parameter Input Type Description x numbers.Integral the baseline where to start writing text. y numbers.Integral the left offset where to start writing a text. body basestring the body string to write.
Example #1:
Python3 `
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:
Python3 `
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 :
Similar Reads
- Wand - sketch() function in Python Sketch is another artistic special effect present in Wand library in python. sketch() function generates a pencil sketched image in output.For best results, radius value should be larger than sigma. Syntax : [GFGTABS] Python3 wand.image.sketch( radius, sigma, angle) # radius should always be greate 2 min read
- Wand rotate() function in Python Rotation changes the orientation of image or it rotates image to a particular angle. rotate() takes a degree which can be 0 to 359. (Actually you can pass 360, 361, or more but it will be the same to 0, 1, or more respectively.). Syntax : wand.image.rotate(degree, background, reset_coords) Parameter 1 min read
- Python - shade() function in Wand shade() function generates a 3d kind of image or creates a 3d effect by simulating a light from an elevated angle. azimuth parameter is used to control the X and Y angle and elevation parameter is used to control the z angle of the image. We can also get final image in grayscale by putting gray para 1 min read
- Wand resize() function in Python Resize image refers to change dimensions of original image in order to convert original image in dimensions that are perfect to use.Scaling Down refers to decrease dimensions of images and make image size smaller. While Scaling Up refers to increase dimensions of an image, and making image size larg 2 min read
- Wand rectangle() function in Python rectangle() function, as the name describes this function is used to draw a circle using wand.drawing object in Python. rectangle takes many arguments like left, top, right, bottom, width, height etc. Syntax : wand.drawing.rectangle(left, top, right, bottom, width, height, radius, xradius, yradius) 2 min read
- Python - sharpen() function in Wand sharpen() function is used in order to enhance blurry edges into more distinct(sharp) edges. This is achieved using a Gaussian function. The radius value should always less than the standard deviation(sigma). Sharpen effect image more clearer and defined. Syntax : wand.image.sharpen(radius, sigma, c 1 min read
- Wand statistic() function in Python Statistic effect is similar to Spread effect, the only difference is that, it replaces each pixel with the result of a mathematical operation performed against neighboring pixel values.The width & height defines the size, or aperture, of the neighboring pixels. The type of statistic operations c 1 min read
- Wand path_start() function in Python We can also draw paths in wand.drawing module. Each path method expects a destination point, and will draw from the current point to the new point. The destination point will become the new current point for the next applied path method. Paths in wand consist of some other methods to draw different 1 min read
- Wand arc() function in Python arc() is a function present in wand.drawing module. arc() function draws an arc in the image. You’ll need to define three pairs of (x, y) coordinates. First & second pair of coordinates will be the minimum bounding rectangle, and the last pair define the starting & ending degree. Syntax : wa 2 min read
- Wand rotate() function - Python The rotate() function is an inbuilt function in the Python Wand ImageMagick library which is used to rotates the image right. It takes a background color for which rotation is not available. Syntax: rotate(degree, background, reset_coords) Parameters: This function accepts three parameters as mentio 2 min read