Home | History | Annotate | Download | only in www
      1 
      2 
      3 
      4 
      5 <!DOCTYPE html>
      6 <html lang="en">
      7 <head>
      8   <meta charset="utf-8"  />
      9   <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no"  />
     10   <title>Image Gradients @ ImageMagick</title>
     11   <meta name="application-name" content="ImageMagick" />
     12   <meta name="description" content="Use ImageMagick to create, edit, compose, or convert bitmap images. You can resize your image, crop it, change its shades and colors, add captions, among other operations." />
     13   <meta name="application-url" content="https://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-2019 ImageMagick Studio LLC" />
     23   <meta name="distribution" content="Global" />
     24   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
     25   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
     26   <link href="../www/gradient.html" rel="canonical" />
     27   <link href="../images/wand.png" rel="icon" />
     28   <link href="../images/wand.ico" rel="shortcut icon" />
     29   <link href="assets/magick.css" rel="stylesheet" />
     30 </head>
     31 <body>
     32   <header>
     33   <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
     34     <a class="navbar-brand" href="../index.html"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../images/wand.ico"/></a>
     35     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation">
     36       <span class="navbar-toggler-icon"></span>
     37     </button>
     38 
     39     <div class="navbar-collapse collapse" id="navbarsMagick" style="">
     40     <ul class="navbar-nav mr-auto">
     41       <li class="nav-item ">
     42         <a class="nav-link" href="../index.html">Home <span class="sr-only">(current)</span></a>
     43       </li>
     44       <li class="nav-item ">
     45         <a class="nav-link" href="download.html">Download</a>
     46       </li>
     47       <li class="nav-item ">
     48         <a class="nav-link" href="command-line-tools.html">Tools</a>
     49       </li>
     50       <li class="nav-item ">
     51         <a class="nav-link" href="command-line-processing.html">Command-line</a>
     52       </li>
     53       <li class="nav-item ">
     54         <a class="nav-link" href="resources.html">Resources</a>
     55       </li>
     56       <li class="nav-item ">
     57         <a class="nav-link" href="develop.html">Develop</a>
     58       </li>
     59       <li class="nav-item">
     60         <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a>
     61       </li>
     62     </ul>
     63     <form class="form-inline my-2 my-lg-0" action="https://imagemagick.org/script/search.php">
     64       <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search">
     65       <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button>
     66     </form>
     67     </div>
     68   </nav>
     69   <div class="container">
     70    <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
     71          style="display:block"
     72          data-ad-client="ca-pub-3129977114552745"
     73          data-ad-slot="6345125851"
     74          data-ad-format="auto"></ins>
     75     <script>
     76       (adsbygoogle = window.adsbygoogle || []).push({});
     77     </script>
     78 
     79   </div>
     80   </header>
     81   <main class="container">
     82     <div class="magick-template">
     83 <div class="magick-header">
     84 
     85 <p class="lead magick-description">An image gradient creates a gradual blend between two colors formed into a shape that is linear, circular, or ellipical.</p>
     86 
     87 <p>For a linear gradient, the operator is either:</p>
     88 
     89 <pre class="highlight"><code>gradient:
     90 gradient:color1-color2
     91 </code></pre>
     92 
     93 <p> The for a radial gradient, the operator is either:</p>
     94 
     95 <pre class="highlight"><code>radial-gradient:
     96 radial-gradient:color1-color2
     97 </code></pre>
     98 
     99 <p> 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.</p> 
    100 
    101 <p>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.</p>
    102 
    103 <p>Gradient colors may be any valid color defined per <a href="color.html" target="_blank">../www/color.html</a>. The named colors of black/white/grayXX and gray(XX[%]) are non-linear gray. For Unix systems, enclose rgb(a) and hex colors in quotes. Use double quotes, if using variables for the values.</p>
    104 
    105 <p>Here is an example linear (as opposed to radial) gradient:</p>
    106 
    107 <pre class="highlight"><code>magick -size 256x256 gradient: linear_gradient.png
    108 magick -size 256x256 gradient:white-black linear_gradient.png
    109 </code></pre>
    110 <p><img src="../images/gradients/linear_gradient.png" width="256" height="256" /></p>
    111 
    112 <p>If you want a radial gradient, try:</p>
    113 
    114 <pre class="highlight"><code>magick -size 256x256 radial-gradient: radial_gradient.png
    115 magick -size 256x256 radial-gradient:white-black radial_gradient.png
    116 </code></pre>
    117 <p><img src="../images/gradients/radial_gradient.png" width="256" height="256" /></p>
    118 
    119 <p>If you want non-linear grayscale gradients, then add -colorspace RGB -colorspace gray 
    120 before saving the output. For example:<p>
    121 
    122 <pre class="highlight"><code>magick -size 256x256 gradient: linear_gradient.png
    123 magick -size 256x256 gradient:white-black -colorspace RGB -colorspace gray linear_linear_gradient.png
    124 </code></pre>
    125 
    126 <pre class="highlight"><code>magick -size 256x256 radial-gradient: radial_gradient.png
    127 magick -size 256x256 radial-gradient:white-black -colorspace RGB -colorspace gray linea_radial_gradient.png
    128 </code></pre>
    129 
    130 <p>As of IM 6.9.2.5, gradients have been enhanced through the use of several -defines.</p>
    131 
    132 <table class="table table-sm table-striped">
    133   <tr>
    134     <td><code>-define gradient:vector=<var>x1</var>,<var>y1</var>, <var>x2</var>,<var>y2</var></code></td>
    135     <td>Specifies the direction of the linear gradient going from vector1 
    136     (x1,y1) to vector2 (x2,y2). Color1 (fromColor) will be located at vector 
    137     position x1,y1 and color2 (toColor) will be located at vector position 
    138     x2,y2.</td>
    139   </tr>
    140 
    141   <tr>
    142     <td><code>-define gradient:center=<var>x</var>,<var>y</var></code></td>
    143     <td>Specifies the coordinates of the center point for the radial gradient. 
    144     The default is the center of the image.</td>
    145   </tr>
    146 
    147   <tr>
    148     <td><code>-define gradient:radii=<var>x</var>,<var>y</var></code></td>
    149     <td>Specifies the x and y radii of the gradient. If the x radius and the y 
    150     radius are equal, the shape of the radial gradient will be a circle. If 
    151     they differ, then the shape will be an ellipse. The default values are the 
    152     maximum of the half width and half height of the image.</td>
    153   </tr>
    154 
    155   <tr>
    156     <td><code>-define gradient:angle=<var>angle in degrees</var></code></td>
    157     <td>For a linear gradient, this specifies the direction of the gradient 
    158     going from color1 to color2 in a clockwise positive manner relative to 
    159     north (up). For a radial gradient, this specifies the rotation of the 
    160     gradient in a clockwise positive manner from its normal X-Y 
    161     orientation.</td>
    162   </tr>
    163 
    164   <tr>
    165     <td><code>-define gradient:bounding-box=<var>width</var>x<var>height</var>+<var>x</var>+<var>y</var></code></td>
    166     <td>Limits the gradient to a larger or smaller region than the image 
    167     dimensions. If the region defined by the bounding box is smaller than the 
    168     image, then color1 will be the color of the background.</td>
    169   </tr>
    170 </table>
    171 
    172 
    173 <p>We also support two convenience defines for setting the linear gradient direction and the radial gradient shape.</p>
    174 
    175 <table class="table table-sm table-striped">
    176   <tr>
    177     <td><code>-define gradient:direction=<em>{NorthWest, North, Northeast, West, East, SouthWest, South, SouthEast}</em></code></td>
    178     <td>Specifies the direction of the linear gradient towards the 
    179     top/bottom/left/right or diagonal corners.</td>
    180   </tr>
    181 
    182   <tr>
    183     <td><code>-define gradient:extent=<em>{Circle, Diagonal, Ellipse, Maximum, Minimum}</em></code></td>
    184     <td>Specifies the shape of an image centered radial gradient. Circle and 
    185     Maximum draw a circular radial gradient even for rectangular shaped images 
    186     of radius equal to the larger of the half-width and half-height of the 
    187     image. The Circle and Maximum options are both equivalent to the default 
    188     radial gradient. The Minimum option draws a circular radial gradient 
    189     even for rectangular shaped images of radius equal to the smaller of the 
    190     half-width and half-height of the image. The Diagonal option draws a 
    191     circular radial gradient even for rectangular shaped images of radius equal 
    192     to the half-diagonal of the image. The Ellipse options draws an elliptical 
    193     radial gradient for rectangular shaped images of radii equal to half the
    194     width and half the height of the image.</td>
    195   </tr>
    196 </table>
    197 
    198 <p>Examples</p>
    199 
    200 <p>The default linear gradient may also be generated in any of the following ways (or by reversing the direction and swapping color1 and color2):</p>
    201 
    202 <pre class="highlight"><code>magick -size 256x128 -define gradient:direction=north gradient:black-white linear_gradient_default.png
    203 magick -size 256x128 -define gradient:angle=0 gradient:black-white linear_gradient_default.png
    204 </code></pre>
    205 <p><img src="../images/gradients/linear_gradient_default.png" width="256" height="128" /></p>
    206 
    207 <p>The equivalent of </p>
    208 
    209 <pre class="highlight"><code>magick -size 128x256 gradient: -rotate 90 linear_gradient_east.png
    210 </code></pre>
    211 
    212 <p>can be generate by either of the following (or by reversing the direction and swapping color1 and color2):</p>
    213 
    214 <pre class="highlight"><code>magick -size 256x128 -define gradient:direction=east gradient:black-white linear_gradient_east.png
    215 magick -size 256x128 -define gradient:angle=90 gradient:black-white linear_gradient_east.png
    216 </code></pre>
    217 <p><img src="../images/gradients/linear_gradient_east.png" width="256" height="128" /></p>
    218 
    219 
    220 <p>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.</p>
    221 
    222 
    223 <pre class="highlight"><code>magick -size 256x128 radial-gradient:black-white radial_gradient_maximum.png
    224 magick -size 256x128 -define gradient:radii=128,128 radial-gradient:black-white radial_gradient_maximum.png
    225 </code></pre>
    226 <p><img src="../images/gradients/radial_gradient_maximum.png" width="256" height="128" /></p>
    227 
    228 <pre class="highlight"><code>magick -size 256x128 -define gradient:extent=minimum radial-gradient:black-white radial_gradient_minimum.png
    229 magick -size 256x128 -define gradient:radii=64,64 radial-gradient:black-white radial_gradient_minimum.png
    230 </code></pre>
    231 <p><img src="../images/gradients/radial_gradient_minimum.png" width="256" height="128" /></p>
    232 
    233 <pre class="highlight"><code>magick -size 256x128 -define gradient:extent=diagonal radial-gradient:black-white radial_gradient_diagonal.png
    234 </code></pre>
    235 <p><img src="../images/gradients/radial_gradient_diagonal.png" width="256" height="128" /></p>
    236 
    237 <pre class="highlight"><code>magick -size 256x128 -define gradient:extent=ellipse radial-gradient:black-white radial_gradient_ellipse.png
    238 magick -size 256x128 -define gradient:radii=128,64 radial-gradient:black-white radial_gradient_ellipse.png
    239 </code></pre>
    240 <p><img src="../images/gradients/radial_gradient_ellipse.png" width="256" height="128" /></p>
    241 
    242 <pre class="highlight"><code>conmagickvert -size 256x256 -define gradient:radii=128,64 -define gradient:angle=45 radial-gradient:black-white radial_gradient_ellipse_angle45.png
    243 </code></pre>
    244 <p><img src="../images/gradients/radial_gradient_ellipse_angle45.png" width="256" height="256" /></p>
    245 
    246 </div>
    247 
    248     </div>
    249   </main><!-- /.container -->
    250   <footer class="magick-footer">
    251     <p><a href="security-policy.html">Security</a> 
    252     <a href="architecture.html">Architecture</a> 
    253     <a href="links.html">Related</a> 
    254      <a href="sitemap.html">Sitemap</a>
    255        
    256     <a href="gradient.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../images/wand.ico"/></a>
    257        
    258     <a href="http://pgp.mit.edu/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    259     <a href="support.html">Donate</a> 
    260     <a href="https://imagemagick.org/script/contact.php">Contact Us</a>
    261     <br/>
    262     <small> 1999-2019 ImageMagick Studio LLC</small></p>
    263   </footer>
    264 
    265   <!-- Javascript assets -->
    266   <script src="assets/magick.js" crossorigin="anonymous"></script>
    267   <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>')</script>
    268 </body>
    269 </html>
    270 <!-- Magick Cache 5th January 2019 11:42 -->