wand.color — Colors

New in version 0.1.2.

class wand.color.Color(string=None, raw=None)

Color value.

Unlike any other objects in Wand, its resource management can be implicit when it used outside of with block. In these case, its resource are allocated for every operation which requires a resource and destroyed immediately. Of course it is inefficient when the operations are much, so to avoid it, you should use color objects inside of with block explicitly e.g.:

red_count = 0
with Color('#f00') as red:
    with Image(filename='image.png') as img:
        for row in img:
            for col in row:
                if col == red:
                    red_count += 1
Parameters:string (basestring) – a color namel string e.g. 'rgb(255, 255, 255)', '#fff', 'white'. see ImageMagick Color Names doc also

See also

ImageMagick Color Names
The color can then be given as a color name (there is a limited but large set of these; see below) or it can be given as a set of numbers (in decimal or hexadecimal), each corresponding to a channel in an RGB or RGBA color model. HSL, HSLA, HSB, HSBA, CMYK, or CMYKA color models may also be specified. These topics are briefly described in the sections below.
== (other)

Equality operator.

Param other:a color another one
Type color:Color
Returns :True only if two images equal.
Rtype :bool
alpha

(numbers.Real) Alpha value, from 0.0 to 1.0.

blue

(numbers.Real) Blue, from 0.0 to 1.0.

static c_equals(a, b)

Raw level version of equality test function for two pixels.

Parameters:
Returns:

True only if two pixels equal

Return type:

bool

Note

It’s only for internal use. Don’t use it directly. Use == operator of Color instead.

green

(numbers.Real) Green, from 0.0 to 1.0.

red

(numbers.Real) Red, from 0.0 to 1.0.

string

(basestring) The string representation of the color.

Related Topics

This Page