Wand color() function in Python (original) (raw)
Last Updated : 16 Mar, 2023
color() function draws a color on the image using current fill color, starting at specified position & method. Uses same arguments as color() method. Following are PAINT_METHOD_TYPES.
- ‘point’ alters a single pixel.
- ‘replace’ swaps on color for another. Threshold is influenced by fuzz.
- ‘floodfill’ fills area of a color influenced by fuzz.
- ‘filltoborder’ fills area of a color until border defined by border_color.
- ‘reset’ replaces the whole image to a single color.
Syntax :
wand.drawing.color(x, y, method)
Parameters :
Parameter Input Type Description x numbers.Integer start of filling color y numbers.Integer end of filling color method basestring method from PAINT_METHOD_TYPES
Example #1:
Python3
from
wand.image
import
Image
from
wand.drawing
import
Drawing
from
wand.color
import
Color
with Drawing() as draw:
`` draw.fill_color
=
Color(
'green'
)
`` draw.color(
100
,
100
,
'point'
)
`` with Image(width
=
200
,
`` height
=
200
,
`` background
=
Color(
'white'
)) as img:
`` draw.draw(img)
`` img.save(filename
=
'color.png'
)
Output: A green pixel is visible at center of transparent image here is the zoomed image. Example #2: Filling color using flood-fill algorithm.
Python3
from
wand.image
import
Image
from
wand.drawing
import
Drawing
from
wand.color
import
Color
with Drawing() as draw:
`` draw.fill_color
=
Color(
'blue'
)
`` draw.alpha(
10
,
35
,
'floodfill'
)
`` with Image(width
=
200
,
`` height
=
200
,
`` background
=
Color(
'white'
)) as img:
`` draw.draw(img)
`` img.save(filename
=
'color2.png'
)
Output:
Similar Reads
- Wand - blur() function in Python Blurring Image means making an image fuzzy or hazy. A blur image is indefinite and it is unable to see an image clearly. Blur is of many types, like - Adaptive blur, Gaussian blur, Selective Blur etc. In order to blur an image we use blur() function. blur() function takes three arguments. Example : 2 min read
- Wand flop() function in Python In this article we will learn what is flop() function. Basically this function returns a flipped image. Flop effect flops an image upside-down or creates an vertical reflection of image. No arguments are needed in this function. Syntax : wand.image.flop()Parameters : No Parameters in flop() function 1 min read
- Wand crop() function in Python Cropping an image refers to select an area of image and discard everything outside the cropped area. Crop tool is an important tool as it allows us to get the only relevant part of an image. Also sometimes something unwanted may be contained in the image and that can be discarded from the image usin 3 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 circle() function in Python The circle() function is another Drawing function in Wand. This method is used to draw a circle in the image. It requires only two arguments that are origin and perimeter of the circle. Syntax: wand.drawing.circle(origin, perimeter)Â Parameters : ParameterInput TypeDescriptionorigin(collections.abc. 2 min read
- Wand flip() function in Python In this article we will learn what is flip() function. Basically this function returns a flipped image. Flip effect flips an image upside-down or creates an vertical reflection of image. No arguments are needed in this function. Syntax : wand.image.flip()Parameters : No Parameters in flip() function 1 min read
- Wand composite() function in Python The composite() function renders an image on top of the drawing subject image using COMPOSITE_OPERATORS. A compositing image must be given with a destination top, left, width, and height values. Syntax: wand.drawing.composite(image, left, top, operator, arguments, gravity) Parameters : Parameter Inp 2 min read
- Wand path_close() function in Python path_close() is another function included in wand for paths. The main aim of this function is to join the last destination point to the first point in the path. It simply adds a path element to the current path which closes the current subpath by drawing a straight line from the current point to the 1 min read
- Wand alpha() function in Python The alpha() function is identical to the wand color() function. Similar to color() function, alpha() function draws a color on the image using current fill color, starting at specified position & method. Uses same arguments as color() method. Syntax: wand.drawing.alpha(x, y, method) Parameters : 2 min read
- Wand function() function in Python function() function is similar to evaluate function. In function() function pixel channels can be manipulated by applies a multi-argument function to pixel channels. Following are the list of FUNCTION_TYPES in Wand: 'undefined''arcsin''arctan''polynomial''sinusoid' Syntax : wand.image.function(funct 1 min read