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

Changed in version 0.3.0: Color objects become hashable.

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.

alpha_int8

(numbers.Integral) Alpha value as 8bit integer which is a common style. From 0 to 255.

New in version 0.3.0.

alpha_quantum

(numbers.Integral) Alpha value. Scale depends on QUANTUM_DEPTH.

New in version 0.3.0.

blue

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

blue_int8

(numbers.Integral) Blue as 8bit integer which is a common style. From 0 to 255.

New in version 0.3.0.

blue_quantum

(numbers.Integral) Blue. Scale depends on QUANTUM_DEPTH.

New in version 0.3.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.

green_int8

(numbers.Integral) Green as 8bit integer which is a common style. From 0 to 255.

New in version 0.3.0.

green_quantum

(numbers.Integral) Green. Scale depends on QUANTUM_DEPTH.

New in version 0.3.0.

normalized_string

(basestring) The normalized string representation of the color. The same color is always represented to the same string.

New in version 0.3.0.

red

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

red_int8

(numbers.Integral) Red as 8bit integer which is a common style. From 0 to 255.

New in version 0.3.0.

red_quantum

(numbers.Integral) Red. Scale depends on QUANTUM_DEPTH.

New in version 0.3.0.

string

(basestring) The string representation of the color.

wand.color.scale_quantum_to_int8(quantum)

Straightforward port of ScaleQuantumToChar() inline function.

Parameters:quantum (numbers.Integral) – quantum value
Returns:8bit integer of the given quantum value
Return type:numbers.Integral

New in version 0.3.0.

Related Topics

This Page