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