blob: dc5ba442b5658987c5b2b7ee435f7135673629de [file] [log] [blame]
Cristy594d2772015-11-15 10:47:42 -05001
2
3
4
Cristy882d9f42015-10-29 16:48:39 -04005<!DOCTYPE html>
6<html lang="en">
7<head>
Cristy594d2772015-11-15 10:47:42 -05008 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
Cristy882d9f42015-10-29 16:48:39 -04009 <title>ImageMagick: Image Gradients</title>
Cristy594d2772015-11-15 10:47:42 -050010 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
11 <meta name="application-name" content="ImageMagick"/>
12 <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves."/>
13 <meta name="application-url" content="http://www.imagemagick.org"/>
14 <meta name="generator" content="PHP"/>
15 <meta name="keywords" content="image, gradients, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
16 <meta name="rating" content="GENERAL"/>
17 <meta name="robots" content="INDEX, FOLLOW"/>
18 <meta name="generator" content="ImageMagick Studio LLC"/>
19 <meta name="author" content="ImageMagick Studio LLC"/>
20 <meta name="revisit-after" content="2 DAYS"/>
21 <meta name="resource-type" content="document"/>
22 <meta name="copyright" content="Copyright (c) 1999-2015 ImageMagick Studio LLC"/>
23 <meta name="distribution" content="Global"/>
24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
25 <link rel="icon" href="../images/wand.png"/>
26 <link rel="shortcut icon" href="../images/wand.ico"/>
27 <link rel="stylesheet" href="../css/magick.html"/>
Cristy882d9f42015-10-29 16:48:39 -040028</head>
29<body>
30<div class="main">
31<div class="magick-masthead">
32 <div class="container">
Cristy594d2772015-11-15 10:47:42 -050033 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
34 style="display:block"
35 data-ad-client="ca-pub-3129977114552745"
36 data-ad-slot="6345125851"
37 data-ad-format="auto"></ins>
Cristy882d9f42015-10-29 16:48:39 -040038 <script>
39 (adsbygoogle = window.adsbygoogle || []).push({});
40 </script>
41 <nav class="magick-nav">
42 <a class="magick-nav-item " href="../index.html">Home</a>
43 <a class="magick-nav-item " href="binary-releases.html">Download</a>
44 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
45 <a class="magick-nav-item " href="command-line-options.html">Options</a>
46 <a class="magick-nav-item " href="resources.html">Resources</a>
47 <a class="magick-nav-item " href="api.html">Develop</a>
48 <a class="magick-nav-item " href="http://nextgen.imagemagick.org/script/search.php">Search</a>
49 <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
50 </nav>
51 </div>
52</div>
53<div class="container">
54<div class="magick-header">
55
56<p class="lead magick-description">An image gradient creates a gradual blend of one color whose shape is linear, circular, or elliptical.</p>
57
58<p>For a linear gradient, use a filename of:</p>
59
60<pre>
61gradient:
62gradient:<var>color1</var>-<var>color2</var>
63</pre>
64
65<p> For a radial gradient, use a filename of:</p>
66
67<pre>
68radial-gradient:
69radial-gradient:<var>color1</var>-<var>color2</var>
70</pre>
71
72<p>Where <var>color1</var> is the from color and <var>color2</var> is the to color as described in more detail below. The default is white for <var>color1</var> and black for <var>color2</var>, i.e., <code>white-black</code>.</p>
73
74<p>The default for a linear gradient starts with <var>color1</var> at the top of the image and <var>color2</var> at the bottom of the image. Similarly, the default for a radial gradient starts with <var>color1</var> at the center of the image and <var>color2</var> at the boundary of the image.</p>
75
76<p>Gradient colors may be any valid <a href="http://www.imagemagick.org/www/color.html">color</a> accepted by ImageMagick. The named colors of <code>black</code>, <code>white</code>, or <code>gray<var>XX</var></code> are non-linear gray gradients; whereas <code>gray<var>XX[%]</var></code> is a linear gray gradient. For Unix systems, enclose <code>rgb(a)</code> and hex colors in quotes. Use double quotes, if using variables for the values.</p>
77
78<p>Here is an example black to white linear gradient:</p>
79
80<pre>
81convert -size 256x256 gradient: linear.png
82</pre>
83
84<p>If you want a black to white radial gradient, try:</p>
85
86<pre>
87convert -size 256x256 radial-gradient: radial.png
88</pre>
89
90<p>As of IM 6.9.2.5, gradients have been modified to be more flexible through the use of <a href="command-line-options.html#define">-define</a>:</p>
91
92<table class="table table-condensed table-striped">
93 <tr>
94 <td><code>-define gradient:bounding-box=<var>width</var>x<var>height</var>+<var>x</var>+<var>y</var></code></td>
95 <td>Limits the gradient to a larger or smaller region than the image
96 dimensions. If the region defined by the bounding box is smaller than the
97 image, color1 is the color of the background.</td>
98 </tr>
99
100 <tr>
101 <td><code>-define gradient:vector="<var>x1</var>,<var>y1</var> <var>x2</var>,<var>y2</var>"</code></td>
102 <td>Specifies the direction of the linear gradient going from vector1
103 (x1,y1) to vector2 (x2,y2). Color1 (from-color) is located at vector
104 position x1,y1 and color2 (to-color) is located at vector position
105 x2,y2.</td>
106 </tr>
107
108 <tr>
109 <td><code>-define gradient:center=<var>x</var>,<var>y</var></code></td>
110 <td>Specifies the coordinates of the center point for the radial gradient.
111 The default is the center of the image.</td>
112 </tr>
113
114 <tr>
115 <td><code>-define gradient:radii=<var>x</var>,<var>y</var></code></td>
116 <td>Specifies the x and y radii of the gradient. If the x radius and the y
117 radius are equal, the shape of the radial gradient is a circle. If
118 they differ, the shape is an ellipse. The default values are the
119 maximum of the half width and half height of the image.</td>
120 </tr>
121
122 <tr>
123 <td><code>-define gradient:angle=<var>angle</var></code></td>
124 <td>For a linear gradient, this define specifies the direction in degrees of the gradient
125 going from color1 to color2 in a clockwise positive manner relative to the
126 positive x axis (east). For a radial gradient, this define specifies the rotation
127 of the gradient in a clockwise positive manner from its normal X-Y
128 orientation.</td>
129 </tr>
130</table>
131
132
133<p>We also support a two convenience defines for setting the linear gradient direction and the radial gradient shape.</p>
134
135<table class="table table-condensed table-striped">
136 <tr>
137 <td><code>-define gradient:direction=<em>{NorthWest, North, Northeast, West, East, SouthWest, South, SouthEast}</em></code></td>
138 <td>Specify the direction of the linear gradient towards the
139 top/bottom/left/right or diagonal corners.</td>
140 </tr>
141
142 <tr>
Cristy594d2772015-11-15 10:47:42 -0500143 <td><code>-define gradient:extent=<em>{Circle, Diagonal, Ellipse, Maximum, Minimum}</code></td>
Cristy882d9f42015-10-29 16:48:39 -0400144 <td>Specify the shape of an image centered radial gradient. Circle and
145 Maximum draw a circular radial gradient even for rectangular shaped images
146 of radius equal to the larger of the half-width and half-height of the
147 image. The Circle and Maximum options are both equivalent to the default
148 radial gradient. The Minimum option draws a circular radial gradient
149 even for rectangular shaped images of radius equal to the smaller of the
150 half-width and half-height of the image. The Diagonal option draws a
151 circular radial gradient even for rectangular shaped images of radius equal
152 to the half-diagonal of the image. The Ellipse options draws an elliptical
153 radial gradient for rectangular shaped images of radii equal to half the
154 width and half the height of the image.</td>
155 </tr>
156</table>
157
158<h3>Examples</h3>
159
160<p>The default linear gradient can be generated in any of the following ways (or by reversing the direction and swapping <var>color1</var> and <var>color2</var>):</p>
161
162<pre>
163convert -size 256x128 -gradient:white-black default_linear_gradient.png
164convert -size 256x128 -define gradient:direction=north -gradient:black-white default_linear_gradient.png
165convert -size 256x128 -define gradient:angle=-90 -gradient:black-white default_linear_gradient.png
166</pre>
167
168<p>The equivalent of</p>
169
170<pre>
171convert -size 128x256 -gradient: -rotate 90 east_linear_gradient.png
172</pre>
173
174<p>can be generated by either of the following (or by reversing the direction and swapping <var>color1</var> and <var>color2</var>):</p>
175
176<pre>
177convert -size 256x128 -define gradient:direction=east gradient:black-white east_linear_gradient.png
178convert -size 256x128 -define gradient:angle=0 gradient:black-white east_linear_gradient.png
179</pre>
180
181
182<p>Examples of radial gradients going from black in the center to white at the boundary for the cases of <code>maximum</code>, <code>circle</code>, <code>default</code>, <code>minimum</code>, <code>diagonal</code>, <code>ellipse</code> and 45 degree rotated ellipse, respectively, follow:</p>
183
184
185<pre>
186convert -size 256x128 gradient:black-white maximum_radial_gradient.png
187convert -size 256x128 -define gradient:radii=128,128 gradient:black-white maximum_radial_gradient.png
188convert -size 256x128 -define gradient:extent=minimum gradient:black-white minimum_radial_gradient.png
189convert -size 256x128 -define gradient:radii=64,64 gradient:black-white minimum_radial_gradient.png
190convert -size 256x128 -define gradient:extent=diagonal gradient:black-white diagonal_radial_gradient.png
191convert -size 256x128 -define gradient:extent=ellipse gradient:black-white ellipse_radial_gradient.png
192convert -size 256x128 -define gradient:radii=128,64 gradient:black-white ellipse_radial_gradient.png
193convert -size 256x256 -define gradient:radii=128x64 -define gradient:angle=45 gradient:black-white ellipse_radial_gradient.png
194</pre>
195</div>
196
197 <footer class="magick-footer">
198 <p><a href="support.html">Donate</a>
199 <a href="sitemap.html">Sitemap</a>
200 <a href="links.html">Related</a>
201 <a href="architecture.html">Architecture</a>
202</p>
203 <p><a href="gradient.html#">Back to top</a>
204 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
205 <a href="http://nextgen.imagemagick.org/script/contact.php">Contact Us</a></p>
206 <p><small>© 1999-2015 ImageMagick Studio LLC</small></p>
207 </footer>
208</div><!-- /.container -->
209
210 <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
211 <script src="http://nextgen.imagemagick.org/js/magick.html"></script>
212</div>
213</body>
214</html>