blob: 4c478c54c19b9acc34805862a4cc69e7c6cf2f48 [file] [log] [blame]

An image gradient creates a gradual blend between two colors formed into a shape that is linear, circular, or ellipical.

For a linear gradient, the operator is either:

In the above, color1 is the fromColor and color2 is the toColor, as described in more detail below. The default is white for color1 and black for color2, i.e., white-black.

The default for a linear gradient has color1 at the top of the image and color2 at the bottom of the image. Similarly, the default for a radial gradient has color1 at the center of the image and color2 at the boundary of the image.

Gradient colors may be any valid color defined per http://www.imagemagick.org/www/color.html. The named colors of black/white/grayXX are non-linear gray gradients; whereas gray(XX[%]) is a linear gray gradient. For Unix systems, enclose rgb(a) and hex colors in quotes. Use double quotes, if using variables for the values.

Here is an example linear gradient:

As of IM 6.9.2.5, gradients have been enhanced through the use of several -defines.

-define gradient:vector=x1,y1, x2,y2 Specifies the direction of the linear gradient going from vector1 (x1,y1) to vector2 (x2,y2). Color1 (fromColor) will be located at vector position x1,y1 and color2 (toColor) will be located at vector position x2,y2.
-define gradient:center=x,y Specifies the coordinates of the center point for the radial gradient. The default is the center of the image.
-define gradient:radii=x,y Specifies the x and y radii of the gradient. If the x radius and the y radius are equal, the shape of the radial gradient will be a circle. If they differ, then the shape will be an ellipse. The default values are the maximum of the half width and half height of the image.
-define gradient:angle=angle in degrees For a linear gradient, this specifies the direction of the gradient going from color1 to color2 in a clockwise positive manner relative to north (up). For a radial gradient, this specifies the rotation of the gradient in a clockwise positive manner from its normal X-Y orientation.
-define gradient:bounding-box=widthxheight+x+y Limits the gradient to a larger or smaller region than the image dimensions. If the region defined by the bounding box is smaller than the image, then color1 will be the color of the background.

We also support two convenience defines for setting the linear gradient direction and the radial gradient shape.

-define gradient:direction={NorthWest, North, Northeast, West, East, SouthWest, South, SouthEast} Specifies the direction of the linear gradient towards the top/bottom/left/right or diagonal corners.

Examples

The default linear gradient may also be generated in any of the following ways (or by reversing the direction and swapping color1 and color2):

The equivalent of

can be generate by either of the following (or by reversing the direction and swapping color1 and color2):

Examples of radial gradients going from black in the center to white at the boundary for the cases of "maximum/circle/default", "minimum", "diagonal", "ellipse" and 45 degree rotated ellipse, respectively, follow below.