blob: 6d0de8c31fb07e3b4d70d30931f6fee21a8740b0 [file] [log] [blame]
cristyad41c0c2012-10-31 00:49:28 +00001
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4<html version="-//W3C//DTD XHTML 1.1//EN"
5 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
6 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7 xsi:schemaLocation="http://www.w3.org/1999/xhtml
8 http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
9<head>
10 <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
11 <meta name="google-site-verification" content="MxsMq6bdLOx0KSuz1MY6yG9ZTIJ7_7DVRfl5NCAT5Yg"/>
cristyffb69ed2010-12-25 00:06:48 +000012 <title>ImageMagick: The Fx Special Effects Image Operator</title>
cristy751980d2012-06-03 23:18:35 +000013 <meta http-equiv="content-language" content="en-US"/>
14 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
15 <meta http-equiv="reply-to" content="magick-users@imagemagick.org"/>
16 <meta name="application-name" content="ImageMagick"/>
17 <meta name="description" content="Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition resize, rotate, shear, distort and transform images automagically."/>
18 <meta name="application-url" content="http://www.imagemagick.org"/>
19 <meta name="generator" content="PHP"/>
20 <meta name="keywords" content="the, fx, special, effects, image, operator, ImageMagick, PerlMagick, image processing, OpenMP, software development library, image, photo, software, Magick++, MagickWand"/>
21 <meta name="rating" content="GENERAL"/>
22 <meta name="robots" content="INDEX, FOLLOW"/>
23 <meta name="generator" content="ImageMagick Studio LLC"/>
24 <meta name="author" content="ImageMagick Studio LLC"/>
25 <meta name="revisit-after" content="2 DAYS"/>
26 <meta name="resource-type" content="document"/>
cristy45ef08f2012-12-07 13:13:34 +000027 <meta name="copyright" content="Copyright (c) 1999-2013 ImageMagick Studio LLC"/>
cristy751980d2012-06-03 23:18:35 +000028 <meta name="distribution" content="Global"/>
cristydcca3fa2010-12-29 21:50:07 +000029 <link rel="icon" href="../images/wand.png"/>
cristy3c98a4f2010-08-13 20:09:41 +000030 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"/>
cristyad41c0c2012-10-31 00:49:28 +000031 <link rel="canonical" href="http://www.imagemagick.org" />
32 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
33 <!-- Add jQuery library -->
cristy18b955e2013-02-24 21:06:33 +000034 <script type="text/javascript" src="http://localhost/ajax/libs/jquery/1.7/jquery.min.js"></script>
cristyad41c0c2012-10-31 00:49:28 +000035
36 <!-- Optionaly include easing and/or mousewheel plugins -->
37 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.easing-1.3.pack.js"></script>
38 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>
39
40 <!-- Add fancyBox -->
41 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/jquery.fancybox.css?v=2.0.4" type="text/css" media="screen" />
42 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.fancybox.pack.js?v=2.0.4"></script>
43
44 <!-- Optionaly include button and/or thumbnail helpers -->
45 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.css?v=2.0.4" type="text/css" media="screen" />
46 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.js?v=2.0.4"></script>
47
48 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.css?v=2.0.4" type="text/css" media="screen" />
49 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.js?v=2.0.4"></script>
50 <script type="text/javascript">
51 $(document).ready(function() {
52 $(".fancybox").fancybox();
53 });
54 </script>
55 <!-- ImageMagick style -->
cristy6ad765e2013-02-24 22:14:01 +000056 <link rel="stylesheet" href="http://www.localhost/cse/style/look/default.css" type="text/css" />
cristyad41c0c2012-10-31 00:49:28 +000057 <style type="text/css" media="all">
58 @import url("../www/magick.css");
59 </style>
60</head>
61
62<body id="www-imagemagick-org">
63<div class="titlebar">
64<div style="margin: 17px auto; float: left;">
65 <script type="text/javascript">
66 <!--
67 google_ad_client = "pub-3129977114552745";
68 google_ad_slot = "5439289906";
69 google_ad_width = 728;
70 google_ad_height = 90;
71 //-->
72 </script>
73 <script type="text/javascript"
cristy18b955e2013-02-24 21:06:33 +000074 src="http://localhost/pagead/show_ads.js">
cristyad41c0c2012-10-31 00:49:28 +000075 </script>
76</div>
77<a href="../discourse-server">
78 <img src="../images/logo.jpg"
79 alt="ImageMagick Logo"
80 style="width: 123px; height: 118px; border: 0px; float: right;" /></a>
81<a href="../index.html">
82 <img src="../images/sprite.jpg"
83 alt="ImageMagick Sprite"
84 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
85</div>
86
87<div class="westbar">
88
cristy3ed852e2009-09-05 21:47:34 +000089<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000090 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
cristy3ed852e2009-09-05 21:47:34 +000091</div>
cristy3ed852e2009-09-05 21:47:34 +000092<div class="menu">
cristy751980d2012-06-03 23:18:35 +000093 <a title="Binary Releases" href="binary-releases.html">Binary Releases</a>
cristybb503372010-05-27 20:51:26 +000094</div>
95<div class="sub">
cristy751980d2012-06-03 23:18:35 +000096 <a title="Binary Release: Unix" href="binary-releases.html#unix">Unix</a>
cristybb503372010-05-27 20:51:26 +000097</div>
98<div class="sub">
cristy751980d2012-06-03 23:18:35 +000099 <a title="Binary Release: MacOS X" href="binary-releases.html#macosx">Mac OS X</a>
cristybb503372010-05-27 20:51:26 +0000100</div>
101<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000102 <a title="Binary Release: iOS" href="binary-releases.html#iOS">iOS</a>
cristyda16f162011-02-19 23:52:17 +0000103</div>
104<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000105 <a title="Binary Release: Windows" href="binary-releases.html#windows">Windows</a>
cristybb503372010-05-27 20:51:26 +0000106</div>
cristyad41c0c2012-10-31 00:49:28 +0000107<div class="sep"></div>
cristybb503372010-05-27 20:51:26 +0000108<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000109 <a title="Command-line Tools" href="command-line-tools.html">Command-line Tools</a>
cristy3ed852e2009-09-05 21:47:34 +0000110</div>
111<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000112 <a title="Command-line Tools: Processing" href="command-line-processing.html">Processing</a>
cristy3ed852e2009-09-05 21:47:34 +0000113</div>
114<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000115 <a title="Command-line Tools: Options" href="command-line-options.html">Options</a>
cristy3ed852e2009-09-05 21:47:34 +0000116</div>
117<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000118 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
cristy3ed852e2009-09-05 21:47:34 +0000119</div>
120<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000121 <a title="Program Interfaces" href="api.html">Program Interfaces</a>
cristy3ed852e2009-09-05 21:47:34 +0000122</div>
123<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000124 <a title="Program Interface: MagickWand" href="magick-wand.html">MagickWand</a>
cristy3ed852e2009-09-05 21:47:34 +0000125</div>
126<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000127 <a title="Program Interface: MagickCore" href="magick-core.html">MagickCore</a>
cristy3ed852e2009-09-05 21:47:34 +0000128</div>
129<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000130 <a title="Program Interface: PerlMagick" href="perl-magick.html">PerlMagick</a>
cristy3ed852e2009-09-05 21:47:34 +0000131</div>
132<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000133 <a title="Program Interface: Magick++" href="magick++.html">Magick++</a>
cristy3ed852e2009-09-05 21:47:34 +0000134</div>
cristyad41c0c2012-10-31 00:49:28 +0000135<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000136<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000137 <a title="Install from Source" href="install-source.html">Install from Source</a>
cristy3ed852e2009-09-05 21:47:34 +0000138</div>
139<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000140 <a title="Install from Source: Unix" href="install-source.html#unix">Unix</a>
cristy3ed852e2009-09-05 21:47:34 +0000141</div>
142<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000143 <a title="Install from Source: Windows" href="install-source.html#windows">Windows</a>
cristy3ed852e2009-09-05 21:47:34 +0000144 </div>
145<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000146 <a title="Resources" href="resources.html">Resources</a>
cristy3ed852e2009-09-05 21:47:34 +0000147</div>
cristybb503372010-05-27 20:51:26 +0000148<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000149 <a title="Architecture" href="architecture.html">Architecture</a>
cristybb503372010-05-27 20:51:26 +0000150</div>
cristy3ed852e2009-09-05 21:47:34 +0000151<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000152 <a title="Download" href="download.html">Download</a>
cristy3ed852e2009-09-05 21:47:34 +0000153</div>
cristyad41c0c2012-10-31 00:49:28 +0000154<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000155<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000156 <a title="Search" href="search.html">Search</a>
cristy3ed852e2009-09-05 21:47:34 +0000157</div>
cristyad41c0c2012-10-31 00:49:28 +0000158<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000159<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000160 <a title="Site Map" href="sitemap.html">Site Map</a>
cristy3ed852e2009-09-05 21:47:34 +0000161</div>
162<div class="sub">
cristy751980d2012-06-03 23:18:35 +0000163 <a title="Site Map: Links" href="links.html">Links</a>
cristy3ed852e2009-09-05 21:47:34 +0000164</div>
cristyad41c0c2012-10-31 00:49:28 +0000165<div class="sep"></div>
cristyeed6cb62012-01-28 19:38:34 +0000166<div class="menu">
cristy751980d2012-06-03 23:18:35 +0000167 <a rel="follow" title="Sponsors" href="sponsors.html">Sponsors:</a>
cristy3ed852e2009-09-05 21:47:34 +0000168
cristyeed6cb62012-01-28 19:38:34 +0000169 <a href="http://www.networkredux.com"> <img src="../images/networkredux.png" width="140" height="31" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a>
cristy751980d2012-06-03 23:18:35 +0000170 <a href="http://www.dinodirect.com/ipads-tablets/"> <img src="../images/dino-direct.jpg" width="140" height="90" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a><!-- 201208010120 mickey@163... -->
cristy3ed852e2009-09-05 21:47:34 +0000171<div class="sponsbox">
cristyeed6cb62012-01-28 19:38:34 +0000172<div class="sponsor">
cristy751980d2012-06-03 23:18:35 +0000173 <a rel="follow" title="Sponsor: The Fastest &amp; Easiest Way to Find Images" href="http://www.graphicsfactory.com">The Fastest &amp; Easiest Way to Find Images</a><!-- 201210010270 graphicsfac... -->
cristy81492d62011-06-07 16:41:42 +0000174</div>
cristyeed6cb62012-01-28 19:38:34 +0000175<div class="sponsor">
cristy751980d2012-06-03 23:18:35 +0000176 <a rel="follow" title="Sponsor: VPS" href="http://www.interdominios.com/vps">VPS</a><!-- 201209010090 barsh@inter... -->
cristy1efc1ab2011-08-01 14:47:02 +0000177</div>
cristyeed6cb62012-01-28 19:38:34 +0000178<div class="sponsor">
cristy751980d2012-06-03 23:18:35 +0000179 <a rel="follow" title="Werbebanner Werbeplane" href="http://www.allesbanner.de">Werbebanner Werbeplane</a><!-- 201212010450 info@druck... -->
180</div>
181<div class="sponsor">
182 <a rel="follow" title="Entertainment News &amp; Photos" href="http://www.zimbio.com">Entertainment News &amp; Photos</a><!-- 201211010540 bd@zimb... -->
183</div>
184<div class="sponsor">
185 <a rel="follow" title="Sponsor: LED24" href="http://led24.de/">LED24</a><!-- 201207010270 info@led24... -->
186</div>
187<div class="sponsor">
188 <a rel="follow" title="Sponsor: Best Website Hosting" href="http://www.top-cheap-web-hosting.com">Best Website Hosting</a><!-- 201304010090 eunge.liu-->
189</div>
190<div class="sponsor">
191 <a rel="follow" title="Android Tablet" href="http://www.dinodirect.com/ipads-tablets/">Android Tablet</a><!-- 201208010120 mickey@163... -->
cristy84134182011-06-15 22:59:00 +0000192</div>
cristyeed6cb62012-01-28 19:38:34 +0000193<div class="sponsor">
194 <a rel="follow" title="Sponsor: Web Site Hosting" href="http://webhostinggeeks.com">Web Site Hosting</a><!-- 201302010900 funds@enmob... -->
cristy81492d62011-06-07 16:41:42 +0000195</div>
cristyeed6cb62012-01-28 19:38:34 +0000196<div class="sponsor">
cristyeed6cb62012-01-28 19:38:34 +0000197 <a rel="follow" title="Sponsor: Premium Quality Stock Photos" href="http://www.f1online.pro/en/">Premium Quality Stock Photos</a><!-- 2012080100540 ... -->
198</div>
199<div class="sponsor">
cristyeed6cb62012-01-28 19:38:34 +0000200 <a rel="follow" title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 2012070100250 ... -->
201</div>
202<div class="sponsor">
203 <a rel="follow" title="Sponsor: Managed Server" href="http://www.robhost.de">Managed Server</a><!-- 201210010720 klikics... -->
204</div>
205<div class="sponsor">
cristy10549a12011-05-15 19:04:46 +0000206 <a rel="follow" title="Sponsor: Druckerei" href="http://www.allesdruck.de">Druckerei</a><!-- 201303011500 r.leo -->
cristy4c54bbb2011-03-17 13:53:13 +0000207</div>
cristyeed6cb62012-01-28 19:38:34 +0000208<div class="sponsor">
209 <a rel="follow" title="Sponsor: Free Catalogs" href="http://www.who-sells-it.com/">Free Catalogs</a><!-- 20120801000600 -->
cristy4bf6e232011-05-21 01:43:33 +0000210</div>
cristyeed6cb62012-01-28 19:38:34 +0000211<div class="sponsor">
cristy751980d2012-06-03 23:18:35 +0000212 <a rel="follow" title="Sponsor: Web Hosting" href="http://www.hostucan.com">Web Hosting</a><!-- 2012120100150 racent marketing@webhosting...-->
cristyec6b4752011-01-08 03:16:23 +0000213</div>
cristy3ed852e2009-09-05 21:47:34 +0000214</div>
cristyce69bb02010-07-27 19:49:46 +0000215</div>
cristyad41c0c2012-10-31 00:49:28 +0000216</div>
217
218<div class="eastbar">
219 <div class="g-plusone" id="gplusone"></div>
220 <script type="text/javascript">
221 window.___gcfg = {
222 lang: 'en-US'
223 };
224
225 (function() {
cristy18b955e2013-02-24 21:06:33 +0000226 var po = document.createElement('offline-script');
cristyad41c0c2012-10-31 00:49:28 +0000227 po.type = 'text/javascript'; po.async = true;
cristy6ad765e2013-02-24 22:14:01 +0000228 po.src = 'https://apis.localhost/js/plusone.js';
cristy18b955e2013-02-24 21:06:33 +0000229 var script = document.getElementsByTagName('offline-script')[0];
cristyad41c0c2012-10-31 00:49:28 +0000230 script.parentNode.insertBefore(po, script);
231 })();
232 var gplusone = document.getElementById("gplusone");
233 gplusone.setAttribute("data-size","medium");
234 gplusone.setAttribute("data-count","false");
235 </script>
236</div>
237
238<div class="main">
239
cristydcca3fa2010-12-29 21:50:07 +0000240<h1>Apply Special Effects to an Image with an Fx Expression</h1>
cristy751980d2012-06-03 23:18:35 +0000241<p class="navigation-index">[<a href="fx.html#fx">The Fx Special Effects Image Operator</a> &bull; <a href="fx.html#anatomy">The Anatomy of an Fx Expression</a>]</p>
cristy3ed852e2009-09-05 21:47:34 +0000242
cristydcca3fa2010-12-29 21:50:07 +0000243<a id="fx"></a>
cristy3ed852e2009-09-05 21:47:34 +0000244<div class="doc-section">
245
246<p>Use the Fx special effects image operator to apply a mathematical expression to an image or image channels. Use Fx to:</p>
247
248<ul>
249 <li>create canvases, gradients, mathematical colormaps</li>
250 <li>move color values between images and channels</li>
251 <li>translate, flip, mirror, rotate, scale, shear and generally distort images</li>
252 <li>merge or composite multiple images together</li>
253 <li>convolve or merge neighboring pixels together</li>
254 <li>generate image metrics or 'fingerprints'</li>
255</ul>
256
257<p>The expression can be simple:</p>
258
cristyeed6cb62012-01-28 19:38:34 +0000259<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert -size 64x64 canvas:black -channel blue -fx "1/2" fx_navy.png</span></p>
cristy3ed852e2009-09-05 21:47:34 +0000260<p>Here, we convert a black to a navy blue image:</p>
261
262<p class="image">
263 <a href="../images/black.png"><img src="../images/black.png" width="64" height="64" alt="black" /></a>
264 <img style="margin-top:22px; margin-bottom:22px;" src="../images/right.gif" width="20" height="20" alt="==>" />
265 <a href="../images/navy.png"><img src="../images/navy.png" width="64" height="64" alt="navy" /></a>
266</p>
267
268<p>Or the expression can be complex:</p>
269
cristyeed6cb62012-01-28 19:38:34 +0000270<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert rose.jpg \ <br/>
cristy3ed852e2009-09-05 21:47:34 +0000271 -fx "(1.0/(1.0+exp(10.0*(0.5-u)))-0.006693)*1.0092503" \ <br/>
272 rose-sigmoidal.png</span></p>
273<p>This expression results in a high contrast version of the image:</p>
274
275<p class="image">
276 <a href="../images/rose.jpg"><img src="../images/rose.jpg" width="70" height="46" alt="rose" /></a>
277 <img style="margin-top:13px; margin-bottom:13px;" src="../images/right.gif" width="20" height="20" alt="==>" />
278 <a href="../images/rose-sigmoidal.png"><img src="../images/rose-sigmoidal.png" width="70" height="46" alt="rose-sigmoidal" /></a>
279</p>
280
281<p>The expression can include variable assignments. Assignments, in most cases, reduce the complexity of an expression and permit some operations that might not be possible any other way. For example, lets create a radial gradient:</p>
282
cristyeed6cb62012-01-28 19:38:34 +0000283<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert -size 70x70 canvas: \ <br/>
cristy3ed852e2009-09-05 21:47:34 +0000284 -fx "Xi=i-w/2; Yj=j-h/2; 1.2*(0.5-hypot(Xi,Yj)/70.0)+0.5" \ <br/>
285 radial-gradient.png</span></p>
286<p>The command above returns this image:</p>
287
288<p class="image">
289 <a href="../images/radial-gradient.png"><img src="../images/radial-gradient.png" width="70" height="70" alt="radial-gradient" /></a>
290</p>
cristye9a32c32011-04-07 01:11:05 +0000291
292<p>This FX expression adds random noise to an image:</p>
293
cristyeed6cb62012-01-28 19:38:34 +0000294<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert photo.jpg -fx 'iso=32; rone=rand(); rtwo=rand(); \<br />
cristye9a32c32011-04-07 01:11:05 +0000295 myn=sqrt(-2*ln(rone))*cos(2*Pi*rtwo); myntwo=sqrt(-2*ln(rtwo))* \<br />
296 cos(2*Pi*rone); pnoise=sqrt(p)*myn*sqrt(iso)* \ <br />
297 channel(4.28,3.86,6.68,0)/255; max(0,p+pnoise)' noisy.png</span></p>
cristy3ed852e2009-09-05 21:47:34 +0000298<p>See <a href="http://www.imagemagick.org/Usage/transform/index.html#fx">Using FX, The Special Effects Image Operator</a> for more examples.</p>
299
300<p>The next section discusses the Fx expression language.</p>
301
302</div>
303
cristydcca3fa2010-12-29 21:50:07 +0000304<h2><a id="anatomy"></a>The Anatomy of an Fx Expression</h2>
cristy3ed852e2009-09-05 21:47:34 +0000305<div class="doc-section">
306
307<h3>The Fx Expression Language</h3>
308<div class="doc-section">
309
310<p>The formal Fx expression language is defined here:</p>
311
312<dl class="doc">
313 <dt class="doc"> numbers:</dt>
cristyeed6cb62012-01-28 19:38:34 +0000314 <dd> integer, floating point, scientfic notation (+/- required, e.g. 3.81469e-06), International System number postfixes (.e.g KB, Mib, GB, etc.)</dd>
cristy3ed852e2009-09-05 21:47:34 +0000315 <dt class="doc"> constants: </dt>
cristyeed6cb62012-01-28 19:38:34 +0000316 <dd> E (Euler's number), Epsilon, QuantumRange, QuantumScale, Opaque, Phi (golden ratio), Pi, Transparent</dd>
cristy3ed852e2009-09-05 21:47:34 +0000317 <dt class="doc"> Fx operators (in order of precedence): </dt>
cristyd92fed52010-10-25 13:48:19 +0000318 <dd> ^ (power), unary -, *, /, % (modulo), +, -,
cristy3ed852e2009-09-05 21:47:34 +0000319 &lt;&lt;, &gt;&gt;, &lt;, &lt;=, &gt;, &gt;=, ==, !=,
320 &amp; (bitwise AND), | (bitwise OR),
321 &amp;&amp; (logical AND), || (logical OR),
322 ~ (logical NOT), ?: (ternary conditional)</dd>
323 <dt class="doc"> math functions: </dt>
cristyeed6cb62012-01-28 19:38:34 +0000324 <dd> abs(), acos(), acosh(), airy(), alt(), asin(), asinh(), atan(), atanh(), atan2(), ceil(), cos(), cosh(), debug(), drc(), exp(), floor(), gauss(), gcd(), hypot(), int(), isnan(), j0(), j1(), jinc(), ln(), log(), logtwo(), max(), min(), mod(), not(), pow(), rand(), round(), sign(), sin(), sinc(), sinh(), sqrt(), squish(), tan(), tanh(), trunc()</dd>
cristy3ed852e2009-09-05 21:47:34 +0000325 <dt class="doc"> channel functions: </dt>
326 <dd> channel(r,g,b,a), channel(c,m,y,k,a)</dd>
327 <dt class="doc"> color names:</dt>
328 <dd> red, cyan, black, etc.</dd>
329 <dt class="doc"> color functions:</dt>
cristy751980d2012-06-03 23:18:35 +0000330 <dd> srgb(), srgba(), rgb(), rgba(), cmyk(), cmyka(), hsl(), hsla(), etc.</dd>
cristy3ed852e2009-09-05 21:47:34 +0000331 <dt class="doc"> color hex values:</dt>
cristy751980d2012-06-03 23:18:35 +0000332 <dd> #ccc, #cbfed0, #b9e1cc00, etc.</dd>
cristy3ed852e2009-09-05 21:47:34 +0000333 <dt class="doc"> symbols:</dt>
334 <dd style="white-space:pre">
335 s = current image in sequence
336 t = scene number of current image in sequence
337 u = first image in sequence
338 v = second image in sequence
339 n = number of images in sequence
340
341 i = column offset
342 j = row offset
343 p = pixel to use (absolute or relative to current pixel)
344
345 w = width of this image
346 h = height of this image
347 z = channel depth
348
349 r = red value (from RGBA), of a specific or current pixel
350 g = green ''
351 b = blue ''
352 a = alpha ''
353 o = opacity ''
354
355 c = cyan value of CMYK color of pixel
356 y = yellow ''
357 m = magenta ''
358 k = black ''
359
360 intensity = pixel intensity
361
362 hue = pixel hue
363 saturation = pixel saturation
364 lightness = pixel lightness
365 luminance = pixel luminance
366
367 page.width = page width
368 page.height = page height
369 page.x = page x offset
370 page.y = page y offset
371
372 resolution.x = x resolution
373 resolution.y = y resolution
374
375 depth = image depth
376 minima = image minima
377 maxima = image maxima
378 mean = image mean
379 standard_deviation = image standard deviation
380 kurtosis = image kurtosis
381 skewness = image skewness
382 (add a channel specifier to compute a statistic for that channel, e.g. depth.r)
383 </dd>
cristyeed6cb62012-01-28 19:38:34 +0000384 <dt class="doc"> iterators:</dt>
385 <dd> while()</dd>
cristy3ed852e2009-09-05 21:47:34 +0000386</dl>
387
388</div>
389
390<h3>The Fx Expression</h3>
391<div class="doc-section">
392
393<p>An Fx expression may include any combination of the following:</p>
394<ul>
395<li> <em>x</em> <kbd>^</kbd> <em>y</em>: exponentiation (<em>x<sup>y</sup></em>)</li>
396<li> <kbd>(</kbd> ... <kbd>)</kbd>: grouping</li>
397<li> <em>x</em> <kbd>*</kbd> <em>y</em>: multiplication (the asterisk <kbd>*</kbd> is optional, for example, <kbd>2u</kbd> or <kbd>2(x+y)</kbd> are acceptable)</li>
398<li> <em>x</em> <kbd>/</kbd> <em>y</em>: division</li>
399<li> <em>x</em> <kbd>%</kbd> <em>y</em>: modulo</li>
400<li> <em>x</em> <kbd>+</kbd> <em>y</em>: addition</li>
401<li> <em>x</em> <kbd>-</kbd> <em>y</em>: subtraction</li>
402<li> <em>x</em> <kbd>&lt;&lt;</kbd> <em>y</em>: left shift</li>
403<li> <em>x</em> <kbd>&gt;&gt;</kbd> <em>y</em>: right shift</li>
404<li> <em>x</em> <kbd>&lt;</kbd> <em>y</em>: boolean relation, return value 1.0 if <em>x</em> &lt; <em>y</em>, otherwise 0.0</li>
405<li> <em>x</em> <kbd>&lt;=</kbd> <em>y</em>: boolean relation, return value 1.0 if <em>x</em> &lt;= <em>y</em>, otherwise 0.0</li>
406<li> <em>x</em> <kbd>&gt;</kbd> <em>y</em>: boolean relation, return value 1.0 if <em>x</em> &gt; <em>y</em>, otherwise 0.0</li>
407<li> <em>x</em> <kbd>&gt;=</kbd> <em>y</em>: boolean relation, return value 1.0 if <em>x</em> &gt;= <em>y</em>, otherwise 0.0</li>
408<li> <em>x</em> <kbd>==</kbd> <em>y</em>: boolean relation, return value 1.0 if <em>x </em>==<em> y</em>, otherwise 0.0</li>
409<li> <em>x</em> <kbd>!=</kbd> <em>y</em>: boolean relation, return value 1.0 if <em>x </em>!=<em> y</em>, otherwise 0.0</li>
410<li> <em>x</em> <kbd>&amp;</kbd> <em>y</em>: binary AND</li>
411<li> <em>x</em> <kbd>|</kbd> <em>y</em>: binary OR</li>
412<li> <em>x</em> <kbd>&amp;&amp;</kbd> <em>y</em>: logical AND connective, return value 1.0 if <em>x</em> &gt; 0 and <em>y</em> &gt; 0, otherwise 0.0</li>
413<li> <em>x</em> <kbd>||</kbd> <em>y</em>: logical OR connective (inclusive), return value 1.0 if <em>x</em> &gt; 0 or <em>y</em> &gt; 0 (or both), otherwise 0.0</li>
414<li> <kbd>~</kbd><em>x</em>: logical NOT operator, return value 1.0 if <em>not</em> <em>x</em> &gt; 0, otherwise 0.0</li>
415<li> <kbd>+</kbd><em>x</em>: unary plus, return 1.0*value</li>
416<li> <kbd>-</kbd><em>x</em>: unary minus, return -1.0*value</li>
417<li> <em>x</em> <kbd>?</kbd> <em>y</em> : <em>z</em>: ternary conditional expression, return value <em>y</em> if <em>x</em> != 0, otherwise <em>z</em>; only one ternary conditional permitted per statement</li>
418<li> <em>x</em> <kbd>=</kbd> <em>y</em>: assignment; assignment variables are restricted to letter combinations only (e.g. Xi not X1)</li>
419<li> <em>x</em> <kbd>;</kbd> <em>y</em>: statement separator </li>
cristyeed6cb62012-01-28 19:38:34 +0000420<li> <kbd>phi</kbd>: constant (1.618034...)</li>
cristy3ed852e2009-09-05 21:47:34 +0000421<li> <kbd>pi</kbd>: constant (3.141659...)</li>
422<li> <kbd>e</kbd>: constant (2.71828...)</li>
423<li> <kbd>QuantumRange</kbd>: constant maximum pixel value (255 for Q8, 65535 for Q16)</li>
424<li> <kbd>QuantumScale</kbd>: constant 1.0/<kbd>QuantumRange</kbd></li>
425<li> <kbd>intensity</kbd>: pixel intensity; equivalent to 0.299*red+0.587*green+0.114*blue</li>
426<li> <kbd>hue</kbd>: pixel hue</li>
427<li> <kbd>saturation</kbd>: pixel saturation</li>
428<li> <kbd>lightness</kbd>: pixel lightness; equivalent to 0.5*max(red,green,blue) + 0.5*min(red,green,blue)</li>
429<li> <kbd>luminance</kbd>: pixel luminance; equivalent to 0.2126*red + 0.7152*green + 0.0722*blue</li>
430<li> <kbd>red, green, blue</kbd>, etc.: color names</li>
431<li> <kbd>#ccc, #cbfed0, #b9e1cc00</kbd>, etc.: color hex values</li>
432<li> <kbd>rgb(), rgba(), cmyk(), cmyka(), hsl(), hsla()</kbd>: color functions</li>
433<li> <kbd>s, t, u, v, n, i, j, w, h, z, r, g, b, a, o, c, y, m, k</kbd>: symbols</li>
434<li> <kbd>abs(</kbd><em>x</em><kbd>)</kbd>: absolute value function</li>
435<li> <kbd>acos(</kbd><em>x</em><kbd>)</kbd>: arc cosine function</li>
cristy1efc1ab2011-08-01 14:47:02 +0000436<li> <kbd>acosh(</kbd><em>x</em><kbd>)</kbd>: inverse hyperbolic cosine function</li>
cristyeed6cb62012-01-28 19:38:34 +0000437<li> <kbd>airy(</kbd><em>x</em><kbd>)</kbd>: Airy function (max=1, min=0); airy(<em>x</em>)=[jinc(<em>x</em>)]<sup>2</sup>=[2*j1(<em>pi*x</em>)/(<em>pi*x</em>)]<sup>2</sup></li>
438<li> <kbd>alt(</kbd><em>x</em><kbd>)</kbd>: sign alternation function (return 1.0 if int(<em>x</em>) is even, -1.0 if int(<em>x</em>) is odd)</li>
cristy3ed852e2009-09-05 21:47:34 +0000439<li> <kbd>asin(</kbd><em>x</em><kbd>)</kbd>: arc sine function</li>
cristy1efc1ab2011-08-01 14:47:02 +0000440<li> <kbd>asinh(</kbd><em>x</em><kbd>)</kbd>: inverse hyperbolic sine function</li>
cristy3ed852e2009-09-05 21:47:34 +0000441<li> <kbd>atan(</kbd><em>x</em><kbd>)</kbd>: arc tangent function</li>
cristy1efc1ab2011-08-01 14:47:02 +0000442<li> <kbd>atanh(</kbd><em>x</em><kbd>)</kbd>: inverse hyperbolic tangent function</li>
cristy3ed852e2009-09-05 21:47:34 +0000443<li> <kbd>atan2(</kbd><em>y</em>,<em>x</em><kbd>)</kbd>: arc tangent function of two variables</li>
444<li> <kbd>ceil(</kbd><em>x</em><kbd>)</kbd>: smallest integral value not less than argument</li>
445<li> <kbd>channel(</kbd><em>r</em>,<em>g</em>,<em>b</em>,<em>a</em><kbd>)</kbd>: select numeric argument based on current channel</li>
446<li> <kbd>channel(</kbd><em>c</em>,<em>m</em>,<em>y</em>,<em>k</em>,<em>a</em><kbd>)</kbd>: select numeric argument based on current channel</li>
447<li> <kbd>cos(</kbd><em>x</em><kbd>)</kbd>: cosine function</li>
448<li> <kbd>cosh(</kbd><em>x</em><kbd>)</kbd>: hyperbolic cosine function</li>
449<li> <kbd>debug(</kbd><em>x</em><kbd>)</kbd>: print <em>x</em> (useful for debugging your expression)</li>
cristyeed6cb62012-01-28 19:38:34 +0000450<li> <kbd>drc(</kbd><em>x</em>,<em>y</em><kbd>)</kbd>: dynamic range compression (knee curve); drc(<em>x</em>,<em>y</em>)=(<em>x</em>)/(<em>y</em>*(<em>x</em>-1)+1); -1&lt;<em>y</em>&lt;1 </li>
cristy3ed852e2009-09-05 21:47:34 +0000451<li> <kbd>exp(</kbd><em>x</em><kbd>)</kbd>: natural exponential function (<em>e<sup>x</sup></em>)</li>
452<li> <kbd>floor(</kbd><em>x</em><kbd>)</kbd>: largest integral value not greater than argument</li>
cristyeed6cb62012-01-28 19:38:34 +0000453<li> <kbd>gauss(</kbd><em>x</em><kbd>)</kbd>: gaussian function; gauss(<em>x</em>)=exp(<em>-x*x/2</em>)/sqrt(2*pi)</li>
454<li> <kbd>gcd(</kbd><em>x</em>,<em>y</em><kbd>)</kbd>: greatest common denominator</li>
cristy3ed852e2009-09-05 21:47:34 +0000455<li> <kbd>hypot(</kbd><em>x</em>,<em>y</em><kbd>)</kbd>: the square root of x<sup>2</sup>+y<sup>2</sup></li>
456<li> <kbd>int(</kbd><em>x</em><kbd>)</kbd>: greatest integer function (return greatest integer less than or equal to <em>x</em>)</li>
cristyeed6cb62012-01-28 19:38:34 +0000457<li> <kbd>isnan(</kbd><em>x</em><kbd>)</kbd>: return 1.0 if <em>x</em> is NAN, 0.0 otherwise</li>
cristy2c839602010-04-03 02:32:08 +0000458<li> <kbd>j0(</kbd><em>x</em><kbd>)</kbd>: Bessel functions of <em>x</em> of the first kind of order 0</li>
459<li> <kbd>j1(</kbd><em>x</em><kbd>)</kbd>: Bessel functions of <em>x</em> of the first kind of order 1</li>
cristyeed6cb62012-01-28 19:38:34 +0000460<li> <kbd>jinc(</kbd><em>x</em><kbd>)</kbd>: jinc function (max=1, min=-0.1323); jinc(<em>x</em>)=2*j1(pi*<em>x</em>)/(pi*<em>*x</em>)</li>
cristy3ed852e2009-09-05 21:47:34 +0000461<li> <kbd>ln(</kbd><em>x</em><kbd>)</kbd>: natural logarithm function</li>
462<li> <kbd>log(</kbd><em>x</em><kbd>)</kbd>: logarithm base 10</li>
463<li> <kbd>logtwo(</kbd><em>x</em><kbd>)</kbd>: logarithm base 2</li>
464<li> <kbd>ln(</kbd><em>x</em><kbd>)</kbd>: natural logarithm</li>
465<li> <kbd>max(</kbd><em>x</em>, <em>y</em><kbd>)</kbd>: maximum of <em>x</em> and <em>y</em></li>
466<li> <kbd>min(</kbd><em>x</em>, <em>y</em><kbd>)</kbd>: minimum of <em>x</em> and <em>y</em></li>
467<li> <kbd>mod(</kbd><em>x</em>, <em>y</em><kbd>)</kbd>: floating-point remainder function</li>
cristyeed6cb62012-01-28 19:38:34 +0000468<li> <kbd>not(</kbd><em>x</em><kbd>)</kbd>: return 1.0 if <em>x</em> is zero, 0.0 otherwise</li>
cristy3ed852e2009-09-05 21:47:34 +0000469<li> <kbd>pow(</kbd><em>x</em>,<em>y</em><kbd>)</kbd>: power function (<em>x<sup>y</sup></em>)</li>
470<li> <kbd>rand()</kbd>: value uniformly distributed over the interval [0.0, 1.0) with a 2 to the 128th-1 period</li>
471<li> <kbd>round()</kbd>: round to integral value, regardless of rounding direction</li>
472<li> <kbd>sign(</kbd><em>x</em><kbd>)</kbd>: return -1.0 if <em>x</em> is less than 0.0 otherwise 1.0</li>
473<li> <kbd>sin(</kbd><em>x</em><kbd>)</kbd>: sine function</li>
cristyeed6cb62012-01-28 19:38:34 +0000474<li> <kbd>sinc(</kbd><em>x</em><kbd>)</kbd>: sinc function (max=1, min=-0.21); sinc(<em>x</em>)=sin(<em>pi*x</em>)/(<em>pi*x</em>)</li>
cristy751980d2012-06-03 23:18:35 +0000475<li> <kbd>squish(</kbd><em>x</em><kbd>)</kbd>: squish function; squish(<em>x</em>)=1.0/(1.0+exp(<em>-x</em>))</li>
cristy3ed852e2009-09-05 21:47:34 +0000476<li> <kbd>sinh(</kbd><em>x</em><kbd>)</kbd>: hyperbolic sine function</li>
477<li> <kbd>sqrt(</kbd><em>x</em><kbd>)</kbd>: square root function</li>
478<li> <kbd>tan(</kbd><em>x</em><kbd>)</kbd>: tangent function</li>
479<li> <kbd>tanh(</kbd><em>x</em><kbd>)</kbd>: hyperbolic tangent function</li>
cristy3c98a4f2010-08-13 20:09:41 +0000480<li> <kbd>trunc(</kbd><em>x</em><kbd>)</kbd>: round to integer, towards zero</li>
cristyeed6cb62012-01-28 19:38:34 +0000481<li> <kbd>while(</kbd><em>condition</em>,<em>expression</em><kbd>)</kbd>: interate while the condition is not equal to 0</li>
cristy3ed852e2009-09-05 21:47:34 +0000482</ul>
483
484<p>The expression semantics include these rules:</p>
485
486<ul>
487<li>symbols are case insensitive</li>
488<li>only one ternary conditional (e.g. x ? y : z) per statement</li>
489<li>statements are assignments or the final expression to return</li>
490<li>an assignment starts a statement, it is not an operator</li>
491<li>assignments to built-ins do not throw an exception and have no effect; e.g. <kbd>r=3.0; r</kbd> returns the pixel red color value, not 3.0</li>
cristyb7b531e2010-10-24 01:41:05 +0000492<li>Unary operators have a lower priority than binary operators, that is, the unary minus (negation) has lower precedence than exponentiation, so -3^2 is interpreted as -(3^2) = -9. Use parentheses to clarify your intent (e.g. (-3)^2 = 9).</li>
cristyce66ab12010-10-21 23:36:32 +0000493<li>Similarly, care must be exercised when using the slash ('/') symbol. The string of characters <em>1/2x</em> is interpreted as (1/2)x. The contrary interpretation should be written explicitly as 1/(2x). Again, the use of parentheses helps clarify the meaning and should be used whenever there is any chance of misinterpretation.</li>
cristy3ed852e2009-09-05 21:47:34 +0000494</ul>
495
cristyce66ab12010-10-21 23:36:32 +0000496
cristy3ed852e2009-09-05 21:47:34 +0000497</div>
498
499<h3>Source Images</h3>
500<div class="doc-section">
501
502<p>The symbols <kbd>u</kbd> and <kbd>v</kbd> refer to the first and second images, respectively, in the current image sequence. Refer to a particular image in a sequence by appending its index to any image reference (usually <kbd>u</kbd>), with a zero index for the beginning of the sequence. A negative index counts from the end. For example, <kbd>u[0]</kbd> is the first image in the sequence, <kbd>u[2]</kbd> is the third, <kbd>u[-1]</kbd> is the last image, and <kbd>u[t]</kbd> is the current image. The current image can also be referenced by <kbd>s</kbd>. If the sequence number exceeds the length of the sequence, the count is wrapped. Thus in a 3-image sequence, <kbd>u[-1]</kbd>, <kbd>u[2]</kbd>, and <kbd>u[5]</kbd> all refer to the same (third) image.</p>
503
504<p>As an example, we form an image by averaging the first image and third images:</p>
505
cristyeed6cb62012-01-28 19:38:34 +0000506<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert image1.jpg image2.jpg image3.jpg -fx "(u+u[2])/2.0" image.jpg</span></p>
cristy3ed852e2009-09-05 21:47:34 +0000507<p>By default, the image to which <kbd>p</kbd>, <kbd>r</kbd>, <kbd>g</kbd>, <kbd>b</kbd>, <kbd>a</kbd>, etc., are applied is the first image <kbd>u</kbd> in the image list, which may also be referenced using <kbd>s</kbd>. </p>
508
cristy751980d2012-06-03 23:18:35 +0000509<p>It is important to note the special role played by the first image. This is the only image in the image sequence that is modified, other images are used only for their data. As an illustrative example, consider the following, and note that the setting <a href="command-line-options.html#channel">-channel red</a> instructs <a href="command-line-options.html#fx">-fx</a> to modify only the red channel; nothing in the green or blue channels will change. It is instructive to ponder why the result is not symmetric.</p>
cristy3ed852e2009-09-05 21:47:34 +0000510
cristyeed6cb62012-01-28 19:38:34 +0000511<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert -channel red logo: -flop logo: -resize "20%" -fx "(u+v)/2" image.jpg</span></p>
cristy3ed852e2009-09-05 21:47:34 +0000512<div class="image">
cristy3ed852e2009-09-05 21:47:34 +0000513 <a href="../images/logo-sm-flop.png"><img src="../images/logo-sm-flop.png" width="128" height="96" alt="logo-sm-flop.png" /></a>
514 <a href="../images/logo-sm.png"><img src="../images/logo-sm.png" width="128" height="96" alt="logo-sm.png" /></a>
515<img style="margin-top:38px; margin-bottom:38px;" src="../images/right.gif" width="20" height="20" alt="==>" />
516 <a href="../images/logo-sm-fx.png"><img src="../images/logo-sm-fx.png" width="128" height="96" alt="logo-sm-fx.png" /></a>
cristy3ed852e2009-09-05 21:47:34 +0000517</div>
518
519
520</div>
521
522<h3>Accessing Pixels</h3>
523<div class="doc-section">
524
525<p>All color values are normalized to the range of 0.0 to 1.0. The alpha channel ranges from 0.0 (fully transparent) to 1.0 (fully opaque).</p>
526
527<p>The pixels are processed one at a time, but a different pixel of an image can be specified using a pixel index represented by <kbd>p</kbd>. For example,</p>
528
529<pre class="text">
530 p[-1].g green value of pixel to the immediate left of the current pixel
531 p[-1,-1].r red value of the pixel diagonally left and up from current pixel
532</pre>
533
534<p>To specify an absolute position, use braces, rather than brackets.</p>
535
536<pre class="text">
cristyee742642011-02-26 02:49:59 +0000537 p{0,0}.r red value of the pixel in the upper left corner of the image
cristy3ed852e2009-09-05 21:47:34 +0000538 p{12,34}.b blue pixel value at column number 12, row 34 of the image
539</pre>
540
cristy751980d2012-06-03 23:18:35 +0000541<p>Integer values of the position retrieve the color of the pixel referenced, while non-integer position values return a blended color according to the current <a href="command-line-options.html#interpolate">-interpolate</a> setting.</p>
cristy3ed852e2009-09-05 21:47:34 +0000542
cristy751980d2012-06-03 23:18:35 +0000543<p>A position outside the boundary of the image retrieves a value dictated by the <a href="command-line-options.html#virtual-pixel">-virtual-pixel</a> option setting.</p>
cristy3ed852e2009-09-05 21:47:34 +0000544
545</div>
546
547<h3>Apply an Expression to Select Image Channels</h3>
548<div class="doc-section">
549
cristy751980d2012-06-03 23:18:35 +0000550<p>Use the <a href="command-line-options.html#channel">-channel</a> setting to specify the output channel of the result. If no output channel is given, the result is set over all channels except the opacity channel. For example, to replace the red channel of <kbd>alpha.png</kbd> with the average of the green channels from the images <kbd>alpha.png</kbd> and <kbd>beta.png</kbd>, use:</p>
cristy3ed852e2009-09-05 21:47:34 +0000551
cristyeed6cb62012-01-28 19:38:34 +0000552<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert alpha.png beta.png -channel red -fx "(u.g+v.g)/2" gamma.png</span></p>
cristy3ed852e2009-09-05 21:47:34 +0000553</div>
554
555<h3>Results</h3>
556<div class="doc-section">
557
cristy751980d2012-06-03 23:18:35 +0000558<p>The <a href="command-line-options.html#fx">-fx</a> operator evaluates the given expression for each channel (set by <a href="command-line-options.html#channel">-channel</a>) of each pixel in the first image (<kbd>u</kbd>) in the sequence. The computed values are temporarily stored in a copy (clone) of that first image until all the pixels have been processed, after which this single new image replaces the list of images in the current image sequence. As such, in the previous example the updated version of <kbd>alpha.png</kbd> replaces both of the original images, <kbd>alpha.png</kbd> and <kbd>beta.png</kbd>, before being saved as <kbd>gamma.png</kbd>.</p>
cristy3ed852e2009-09-05 21:47:34 +0000559
560<p>The current image <kbd>s</kbd> is set to the first image in the sequence (<kbd>u</kbd>), and <kbd>t</kbd> to its index, 0. The symbols <kbd>i</kbd> and <kbd>j</kbd> reference the current pixel being processed.</p>
561
562
cristy751980d2012-06-03 23:18:35 +0000563<p>For use with <a href="command-line-options.html#format_identify_">-format</a>, the value-escape <kbd>%[fx: ]</kbd> is evaluated just once for each image in the current image sequence. As each image in the sequence is being evaluated, <kbd>s</kbd> and <kbd>t</kbd> successively refer to the current image and its index, while <kbd>i</kbd> and <kbd>j</kbd> are set to zero, and the current channel set to red (<a href="command-line-options.html#channel">-channel</a> is ignored). An example:</p>
cristy3ed852e2009-09-05 21:47:34 +0000564
cristyeed6cb62012-01-28 19:38:34 +0000565<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert canvas:'rgb(25%,50%,75%)' rose: -colorspace rgb \ <br/>
cristy3cd7cc92011-04-01 01:00:28 +0000566 -format 'Red channel of NW corner of image #%[fx:t] is %[fx: s]' info:</span><span class='crtout'>Red channel of NW corner of image #0 is 0.453758 <br/>
567 Red channel of NW corner of image #1 is 0.184588</span></p>
568<p>Here we use the image indexes to <em>rotate</em> each image differently, and use <kbd>-set</kbd> with the image index to set a different <em>pause delay</em> on the first image in the animation:</p>
569
cristyeed6cb62012-01-28 19:38:34 +0000570<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert rose: -duplicate 29 -virtual-pixel Gray -distort SRT '%[fx:360.0*t/n]' \ <br />
cristy751980d2012-06-03 23:18:35 +0000571 -set delay '%[fx:t == 0 ? 240 : 10]' -loop 0 rose.gif</span></p><p>The color-escape <kbd>%[pixel: ]</kbd> is evaluated once per image and per color channel in that image (<a href="command-line-options.html#channel">-channel</a> is ignored), The values generated are then converted into a color string (a named color or hex color value). The symbols <kbd>i</kbd> and <kbd>j</kbd> are set to zero, and <kbd>s</kbd> and <kbd>t</kbd> refer to each successively current image and index.</p>
cristy3ed852e2009-09-05 21:47:34 +0000572
573</div>
574</div>
cristyad41c0c2012-10-31 00:49:28 +0000575
576</div>
577
578<div id="linkbar">
579 <span id="linkbar-west">&nbsp;</span>
580 <span id="linkbar-center">
581 <a href="../discourse-server">Discourse Server</a> &bull;
582 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
583 </span>
584 <span id="linkbar-east">&nbsp;</span>
585 </div>
586 <div class="footer">
cristy45ef08f2012-12-07 13:13:34 +0000587 <span id="footer-west">&copy; 1999-2013 ImageMagick Studio LLC</span>
cristyad41c0c2012-10-31 00:49:28 +0000588 <span id="footer-east"> <a href="contact.html">Contact the Wizards</a></span>
589 </div>
590 <div style="clear: both; margin: 0; width: 100%; "></div>
591 <script type="text/javascript">
592 var _gaq = _gaq || [];
593 _gaq.push(['_setAccount', 'UA-17690367-1']);
594 _gaq.push(['_trackPageview']);
595
596 (function() {
cristy18b955e2013-02-24 21:06:33 +0000597 var ga = document.createElement('offline-script'); ga.type = 'text/javascript'; ga.async = true;
cristy6ad765e2013-02-24 22:14:01 +0000598 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.localhost/ga.js';
cristy18b955e2013-02-24 21:06:33 +0000599 var s = document.getElementsByTagName('offline-script')[0]; s.parentNode.insertBefore(ga, s);
cristyad41c0c2012-10-31 00:49:28 +0000600 })();
601 </script>
602</body>
603</html>