blob: 9b7243e1387b7026509d6f660bbf606c949fd226 [file] [log] [blame]
cristy3eaa0ef2010-03-06 20:35:26 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
cristy2c839602010-04-03 02:32:08 +00003<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
cristy3eaa0ef2010-03-06 20:35:26 +00004<head>
cristy3c98a4f2010-08-13 20:09:41 +00005 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6 <meta name="verify-v1" content="g222frIIxcQTrvDR3NBRUSKP3AnMNoqxOkIniCEkV7U="/>
cristyffb69ed2010-12-25 00:06:48 +00007 <title>ImageMagick: PerlMagick, Perl API for ImageMagick</title>
cristy3ed852e2009-09-05 21:47:34 +00008 <meta http-equiv="Content-Language" content="en-US"/>
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
10 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
cristy3c98a4f2010-08-13 20:09:41 +000011 <meta name="Application-name" content="ImageMagick"/>
cristyffb69ed2010-12-25 00:06:48 +000012 <meta name="Description" content="ImageMagick is a software suite to create, edit, or compose bitmap images in a variety of formats. Use ImageMagick to scale, rotate, shear, distort and transform images."/>
cristy3c98a4f2010-08-13 20:09:41 +000013 <meta name="Application-url" content="http://www.imagemagick.org"/>
cristy3ed852e2009-09-05 21:47:34 +000014 <meta name="Generator" content="PHP"/>
15 <meta name="Keywords" content="perlmagick, perl, api, for, imagemagick, ImageMagick, ImageMagic, MagickCore, MagickWand, PerlMagick, Magick++, RMagick, PythonMagick, JMagick, TclMagick, Image, Magick, Magic, Wand, ImageMagickObject, Swiss, Army, Knife, Image, Processing"/>
cristy3ed852e2009-09-05 21:47:34 +000016 <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"/>
cristy7e41fe82010-12-04 23:12:08 +000022 <meta name="Copyright" content="Copyright (c) 1999-2011 ImageMagick Studio LLC"/>
cristy3ed852e2009-09-05 21:47:34 +000023 <meta name="Distribution" content="Global"/>
cristy3c98a4f2010-08-13 20:09:41 +000024 <link rel="icon" href="../images/wand.png" sizes="32x32"/>
25 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"/>
26 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
27 <style type="text/css" media="all">
28 @import url("../www/magick.css");
29 </style>
cristy3eaa0ef2010-03-06 20:35:26 +000030</head>
31
32<body id="www-imagemagick-org">
33<div class="titlebar">
34<a href="../index.html">
35 <img src="../images/script.png" alt="[ImageMagick]"
36 style="width: 350px; height: 60px; margin: 28px auto; float: left;" /></a>
37<a href="http://www.networkredux.com">
38 <img src="../images/networkredux.png" alt="[sponsor]"
39 style="margin: 45px auto; border: 0px; float: left;" /></a>
40<a href="http://www.imagemagick.org/discourse-server/">
41 <img src="../images/logo.jpg" alt=""
42 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
43<a href="../index.html">
44 <img src="../images/sprite.jpg" alt=""
45 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
46</div>
47
cristyce69bb02010-07-27 19:49:46 +000048<div class="westbar">
cristy3eaa0ef2010-03-06 20:35:26 +000049
cristy3ed852e2009-09-05 21:47:34 +000050<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000051 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
cristy3ed852e2009-09-05 21:47:34 +000052</div>
cristy3eaa0ef2010-03-06 20:35:26 +000053<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +000054<div class="menu">
cristybb503372010-05-27 20:51:26 +000055 <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
56</div>
57<div class="sub">
58 <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
59</div>
60<div class="sub">
61 <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
62</div>
63<div class="sub">
64 <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
65</div>
66<div class="sep"></div>
67<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000068 <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
cristy3ed852e2009-09-05 21:47:34 +000069</div>
70<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000071 <a title="Command-line Tools: Processing" href="../www/command-line-processing.html">Processing</a>
cristy3ed852e2009-09-05 21:47:34 +000072</div>
73<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000074 <a title="Command-line Tools: Options" href="../www/command-line-options.html">Options</a>
cristy3ed852e2009-09-05 21:47:34 +000075</div>
76<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000077 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
cristy3ed852e2009-09-05 21:47:34 +000078</div>
79<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000080 <a title="Program Interfaces" href="../www/api.html">Program Interfaces</a>
cristy3ed852e2009-09-05 21:47:34 +000081</div>
82<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000083 <a title="Program Interface: MagickWand" href="../www/magick-wand.html">MagickWand</a>
cristy3ed852e2009-09-05 21:47:34 +000084</div>
85<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000086 <a title="Program Interface: MagickCore" href="../www/magick-core.html">MagickCore</a>
cristy3ed852e2009-09-05 21:47:34 +000087</div>
88<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000089 <a title="Program Interface: PerlMagick" href="../www/perl-magick.html">PerlMagick</a>
cristy3ed852e2009-09-05 21:47:34 +000090</div>
91<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000092 <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
cristy3ed852e2009-09-05 21:47:34 +000093</div>
cristy3eaa0ef2010-03-06 20:35:26 +000094<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +000095<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000096 <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
cristy3ed852e2009-09-05 21:47:34 +000097</div>
98<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000099 <a title="Install from Source: Unix" href="../www/install-source.html#unix">Unix</a>
cristy3ed852e2009-09-05 21:47:34 +0000100</div>
101<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000102 <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
cristy3ed852e2009-09-05 21:47:34 +0000103 </div>
104<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000105 <a title="Resources" href="../www/resources.html">Resources</a>
cristy3ed852e2009-09-05 21:47:34 +0000106</div>
cristybb503372010-05-27 20:51:26 +0000107<div class="menu">
108 <a title="Architecture" href="../www/architecture.html">Architecture</a>
109</div>
cristy3ed852e2009-09-05 21:47:34 +0000110<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000111 <a title="Download" href="../www/download.html">Download</a>
cristy3ed852e2009-09-05 21:47:34 +0000112</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000113<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000114<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000115 <a title="Search" href="http://www.imagemagick.org/script/search.php">Search</a>
cristy3ed852e2009-09-05 21:47:34 +0000116</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000117<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000118<div class="menu">
cristyffb69ed2010-12-25 00:06:48 +0000119 <a title="Site Map" href="../www/sitemap.html">Site Map</a>
cristy3ed852e2009-09-05 21:47:34 +0000120</div>
121<div class="sub">
cristyffb69ed2010-12-25 00:06:48 +0000122 <a title="Site Map: Links" href="../www/links.html">Links</a>
cristy3ed852e2009-09-05 21:47:34 +0000123</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000124<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000125<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000126 <a title="Sponsors" href="../www/sponsors.html">Sponsors:</a>
cristy3ed852e2009-09-05 21:47:34 +0000127
128<div class="sponsbox">
129<div class="sponsor">
cristyffb69ed2010-12-25 00:06:48 +0000130 <a title="Sponsor: alaTest.com" href="http://alatest.com">alaTest.com</a><!-- 20110801000300 -->
cristy5c4585b2010-11-11 00:13:57 +0000131</div>
132<div class="sponsor">
cristy7d52cd62010-10-01 17:26:59 +0000133 <a title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 201110010720 -->
134</div>
135<div class="sponsor">
cristyc5baf4f2010-08-31 15:05:33 +0000136 <a title="Sponsor: Image Converter" href="http://www.batchphoto.com">Image Converter</a><!-- 201103010900 Bits Coffee-->
137</div>
138<div class="sponsor">
cristy851dbce2010-08-06 21:40:00 +0000139 <a title="Sponsor: Flyer drucken" href="http://www.online-druck.biz">Flyer drucken</a><!-- 201109010900 Floeter-->
140</div>
141<div class="sponsor">
cristy83a272e2010-05-07 20:40:35 +0000142 <a title="Sponsor: Webdesign Agentur" href="http://www.ventzke-partner.de">Webdesign Agentur</a><!-- 201101010480 invendio.de-->
cristy320dd6e2010-04-16 20:11:40 +0000143</div>
144<div class="sponsor">
cristy83a272e2010-05-07 20:40:35 +0000145 <a title="Sponsor: LVM Versicherung" href="http://www.neu-reich.de">LVM Versicherung</a><!-- 201101010480 -->
cristy8f900122010-03-05 15:26:31 +0000146</div>
147<div class="sponsor">
cristyc5baf4f2010-08-31 15:05:33 +0000148 <a title="Sponsor: Diamonds are a Girls Best Friend" href="http://www.schmuck.org">Diamonds are a Girls Best Friend</a><!-- 201101010600 Peterssen-->
cristy916e1922009-10-01 12:52:47 +0000149</div>
cristy3ed852e2009-09-05 21:47:34 +0000150</div>
151</div>
cristyce69bb02010-07-27 19:49:46 +0000152</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000153
cristyce69bb02010-07-27 19:49:46 +0000154<div class="eastbar">
155 <script type="text/javascript">
156 <!--
157 google_ad_client = "pub-3129977114552745";
cristyce69bb02010-07-27 19:49:46 +0000158 google_ad_slot = "0574824969";
159 google_ad_width = 160;
160 google_ad_height = 600;
161 //-->
162 </script>
163 <script type="text/javascript"
164 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
165 </script>
cristy3eaa0ef2010-03-06 20:35:26 +0000166</div>
167
168<div class="main">
169
170
cristyffb69ed2010-12-25 00:06:48 +0000171<h1>ImageMagick PerlMagick API</h1>
cristy3ed852e2009-09-05 21:47:34 +0000172<p class="navigation-index">[<a href="#installation">Installation</a> &bull; <a href="#overview">Overview</a> &bull; <a href="#example">Example Script</a> &bull; <a href="#read">Read or Write an Image</a> &bull; <a href="#manipulate">Manipulate an Image</a> &bull; <a href="#set-attribute">Set an Image Attribute</a> &bull; <a href="#get-attribute">Get an Image Attribute</a> &bull; <a href="#compare">Compare an Image to its Reconstruction</a> &bull; <a href="#montage">Create an Image Montage</a> &bull; <a href="#blobs">Working with Blobs</a> &bull; <a href="#direct-access">Direct-access to Image Pixels</a> &bull; <a href="#miscellaneous">Miscellaneous Methods</a> &bull; <a href="#exceptions">Handling Exceptions</a>&bull; <a href="#constants">Constant</a> ]</p>
173
174<div class="doc-section">
175<a name="introduction"></a>
cristyf3bb4782009-09-08 13:10:04 +0000176<p><a href="../www/download.html">PerlMagick</a> is an objected-oriented <a href="http://www.perl.com/perl/">Perl</a> interface to ImageMagick. Use the module to read, manipulate, or write an image or image sequence from within a Perl script. This makes it very suitable for Web CGI scripts. You must have ImageMagick 6.5.5 or above and Perl version 5.005_02 or greater installed on your system for PerlMagick to build properly.</p>
cristy3ed852e2009-09-05 21:47:34 +0000177
178<p>There are a number of useful scripts available to show you the value of PerlMagick. You can do Web based image manipulation and conversion with <a href="http://www.imagemagick.org/download/perl">MagickStudio</a>, or use <a href="https://www.imagemagick.org/subversion/ImageMagick/trunk/PerlMagick/demo/">L-systems</a> to create images of plants using mathematical constructs, and finally navigate through collections of thumbnail images and select the image to view with the <a href="http://webmagick.sourceforge.net/">WebMagick Image Navigator</a>.</p>
179
180<p>You can try PerlMagick from your Web browser at the <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">ImageMagick Studio</a>. Or, you can see <a href="../www/examples.html">examples</a> of select PerlMagick functions.</p>
181</div>
182
183<h2><a name="installation"></a>Installation</h2>
184<div class="doc-section">
185
186<p><b>UNIX</b></p>
187
188<p>The following instructions for Unix apply only to the unbundled PerlMagick as obtained from CPAN. PerlMagick is included as a subdirectory (PerlMagick) of the ImageMagick source distribution, and may be configured and built using the instructions provided in the ImageMagick distribution's README.txt file. It is usually most convenient to install PerlMagick as part of the ImageMagick distribution.</p>
189
190<p>ImageMagick must already be installed on your system. Next, get
191the <a href="../www/download.html">PerlMagick</a> distribution corresponding to the installed ImageMagick distribution
cristy61365ad2010-11-28 02:38:34 +0000192(e.g., PerlMagick 6.66 for
193ImageMagick 6.6.6) and unpack it as shown below:</p>
cristy3ed852e2009-09-05 21:47:34 +0000194
cristy61365ad2010-11-28 02:38:34 +0000195<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>tar xvfz PerlMagick-6.66.tar.gz</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>cd PerlMagick</span></p>
cristyf3bb4782009-09-08 13:10:04 +0000196<p>Next, edit <kbd>Makefile.PL</kbd> and change LIBS and INC to include the appropriate path information to the required <kbd>MagickCore</kbd> library. You may need paths to JPEG, PNG, TIFF, etc. delegates if they were included with your installed version of ImageMagick. Build and install it like this:</p>
cristy3ed852e2009-09-05 21:47:34 +0000197
198<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>perl Makefile.PL</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>make</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>make install</span></p>
199<p>For Unix, you typically need to be <kbd>root</kbd> to install the software. There are ways around this. Consult the Perl manual pages for more information.</p>
200
201<p><b>Windows XP / Windows 2000</b></p>
202
203<p>ImageMagick must already be installed on your system. Also, the ImageMagick source distribution for <a href="../www/download.html">Windows 2000</a> is required. You must also have the <kbd>nmake</kbd> from the Visual C++ or J++ development environment. Copy <kbd>\bin\IMagick.dll</kbd> and <kbd>\bin\X11.dll</kbd> to a directory in your dynamic load path such as <kbd>c:\perl\site\5.00502</kbd>.</p>
204
205<p>Next, type</p>
206
207<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>cd PerlMagick</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>perl Makefile.nt</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>nmake</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>nmake install</span></p>
208<p>See the <a href="http://www.dylanbeattie.net/magick/">PerlMagick Windows HowTo</a> page for further installation instructions.</p>
209
210<p><b>Running the Regression Tests</b></p>
211
212<p>To verify a correct installation, type</p>
213
214<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>make test</span></p>
215<p>Use <kbd>nmake test</kbd> under Windows. There are a few demonstration scripts available to exercise many of the functions PerlMagick can perform. Type</p>
216
217<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>cd demo</span><span class='crtout'></span><span class="crtprompt"> $magick&gt; </span><span class='crtin'>make</span></p>
218<p>You are now ready to utilize the PerlMagick methods from within your Perl scripts.</p>
219
220</div>
221
222<h2><a name="overview"></a>Overview</h2>
223<div class="doc-section">
224
225<p>Any script that wants to use PerlMagick methods must first define the methods within its namespace and instantiate an image object. Do this with:</p>
226
227<pre class="code">
228 use Image::Magick;
229
230 $image=Image::Magick-&gt;new;
231</pre>
232
233<p>The new() method takes the same parameters as <a href="#set-attribute">SetAttribute</a> . For example,</p>
234
235<pre class="code">
236 $image=Image::Magick-&gt;new(size=&gt;'384x256');
237</pre>
238
239<p>Next you will want to read an image or image sequence, manipulate it, and then display or write it. The input and output methods for PerlMagick are defined in <a href="#read">Read or Write an Image</a>. See <a href="#set-attribute">Set an Image Attribute</a> for methods that affect the way an image is read or written. Refer to <a href="#manipulate">Manipulate an Image</a> for a list of methods to transform an image. <a href="#get-attribute">Get an Image Attribute</a> describes how to retrieve an attribute for an image. Refer to <a href="#montage">Create an Image Montage</a> for details about tiling your images as thumbnails on a background. Finally, some methods do not neatly fit into any of the categories just mentioned. Review <a href="#misc">Miscellaneous Methods</a> for a list of these methods.</p>
240
cristyc1c61662009-09-30 14:04:37 +0000241<p>Once you are finished with a PerlMagick object you should consider destroying it. Each image in an image sequence is stored in virtual memory. This can potentially add up to mebibytes of memory. Upon destroying a PerlMagick object, the memory is returned for use by other Perl methods. The recommended way to destroy an object is with <kbd>undef</kbd>:</p>
cristy3ed852e2009-09-05 21:47:34 +0000242
243<pre class="code">
244 undef $image;
245</pre>
246
247<p>To delete all the images but retain the <kbd>Image::Magick</kbd> object use</p>
248
249<pre class="code">
250 @$image = ();
251</pre>
252
253<p>and finally, to delete a single image from a multi-image sequence, use</p>
254
255<pre class="code">
256 undef $image-&gt;[$x];
257</pre>
258
259<p>The next section illustrates how to use various PerlMagick methods to manipulate an image sequence.</p>
260
261<p>Some of the PerlMagick methods require external programs such as <a href="http://www.cs.wisc.edu/~ghost/">Ghostscript</a>. This may require an explicit path in your PATH environment variable to work properly. For example (in Unix),</p>
262
263<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>$ENV{PATH}='/../bin:/usr/bin:/usr/local/bin';</span></p>
264<div style="margin: auto;">
265<h2><a name="example"></a>Example Script</h2>
266</div>
267
268<p>Here is an example script to get you started:</p>
269
270<pre class="code">
271 #!/usr/local/bin/perl
272 use Image::Magick;<br />
273 my($image, $x);<br />
274 $image = Image::Magick-&gt;new;
275 $x = $image-&gt;Read('girl.png', 'logo.png', 'rose.png');
276 warn "$x" if "$x";<br />
277 $x = $image-&gt;Crop(geometry=&gt;'100x100+100+100');
278 warn "$x" if "$x";<br />
279 $x = $image-&gt;Write('x.png');
280 warn "$x" if "$x";
281</pre>
282
283<p>The script reads three images, crops them, and writes a single image as a GIF animation sequence. In many cases you may want to access individual images of a sequence. The next example illustrates how this done:</p>
284
285<pre class="code">
286 #!/usr/local/bin/perl
287 use Image::Magick;<br />
288 my($image, $p, $q);<br />
289 $image = new Image::Magick;
290 $image-&gt;Read('x1.png');
291 $image-&gt;Read('j*.jpg');
292 $image-&gt;Read('k.miff[1, 5, 3]');
293 $image-&gt;Contrast();
294 for ($x = 0; $image-&gt;[$x]; $x++)
295 {
296 $image-&gt;[$x]-&gt;Frame('100x200') if $image-&gt;[$x]-&gt;Get('magick') eq 'GIF';
297 undef $image-&gt;[$x] if $image-&gt;[$x]-&gt;Get('columns') &lt; 100;
298 }
299 $p = $image-&gt;[1];
300 $p-&gt;Draw(stroke=&gt;'red', primitive=&gt;'rectangle', points=&gt;20,20 100,100');
301 $q = $p-&gt;Montage();
302 undef $image;
303 $q-&gt;Write('x.miff');
304</pre>
305
306<p>Suppose you want to start out with a 100 by 100 pixel white canvas with a red pixel in the center. Try</p>
307
308<pre class="code">
309 $image = Image::Magick-&gt;new;
310 $image-&gt;Set(size=&gt;'100x100');
311 $image-&gt;ReadImage('xc:white');
312 $image-&gt;Set('pixel[49,49]'=&gt;'red');
313</pre>
314
315<p>Here we reduce the intensity of the red component at (1,1) by half:</p>
316
317<pre class="code">
318 @pixels = $image-&gt;GetPixel(x=&gt;1,y=&gt;1);
319 $pixels[0]*=0.5;
320 $image-&gt;SetPixel(x=&gt;1,y=&gt;1,color=&gt;\@pixels);
321</pre>
322
323<p>Or suppose you want to convert your color image to grayscale:</p>
324
325<pre class="code">
326 $image-&gt;Quantize(colorspace=&gt;'gray');
327</pre>
328
329<p>Let's annotate an image with a Taipai TrueType font:</p>
330
331<pre class="code">
332 $text = 'Works like magick!';
333 $image-&gt;Annotate(font=&gt;'kai.ttf', pointsize=&gt;40, fill=&gt;'green', text=&gt;$text);
334</pre>
335
336<p>Perhaps you want to extract all the pixel intensities from an image and write them to STDOUT:</p>
337
338<pre class="code">
339 @pixels = $image-&gt;GetPixels(map=&gt;'I', height=&gt;$height, width=&gt;$width, normalize=&gt;true);
340 binmode STDOUT;
341 print pack('B*',join('',@pixels));
342</pre>
343
344<p>Other clever things you can do with a PerlMagick objects include</p>
345
346<pre class="code">
347 $i = $#$p"+1"; # return the number of images associated with object p
348 push(@$q, @$p); # push the images from object p onto object q
349 @$p = (); # delete the images but not the object p
350 $p-&gt;Convolve([1, 2, 1, 2, 4, 2, 1, 2, 1]); # 3x3 Gaussian kernel
351</pre>
352
353<div style="margin: auto;">
354 <h2><a name="read"></a>Read or Write an Image</h2>
355</div>
356
357<p>Use the methods listed below to either read, write, or display an image or image sequence:</p>
358
359<table class="doc">
360<caption>Read or Write Methods</caption>
361<colgroup>
362 <col width="20%"></col>
363 <col width="20%"></col>
364 <col width="20%"></col>
365 <col width="40%"></col>
366</colgroup>
367<tbody>
368
369 <tr>
370 <th>Method</th>
371 <th>Parameters</th>
372 <th>Return Value</th>
373 <th>Description</th>
374 </tr>
375
376 <tr>
377 <td valign="top">Read</td>
378 <td valign="top">one or more filenames</td>
379 <td valign="top">the number of images read</td>
380 <td valign="top">read an image or image sequence</td>
381 </tr>
382
383 <tr>
384 <td valign="top">Write</td>
385 <td valign="top">filename</td>
386 <td valign="top">the number of images written</td>
387 <td valign="top">write an image or image sequence</td>
388 </tr>
389
390 <tr>
391 <td valign="top">Display</td>
392 <td valign="top">server name</td>
393 <td valign="top">the number of images displayed</td>
394 <td valign="top">display the image or image sequence to an X server</td>
395 </tr>
396
397 <tr>
398 <td valign="top">Animate</td>
399 <td valign="top">server name</td>
400 <td valign="top">the number of images animated</td>
401 <td valign="top">animate image sequence to an X server</td>
402 </tr>
403</tbody>
404</table>
405
406<p>For convenience, methods Write(), Display(), and Animate() can take any parameter that <a href="#set-attribute">SetAttribute</a> knows about. For example,</p>
407
408<pre class="code">
409 $image-&gt;Write(filename=&gt;'image.png', compression=&gt;'None');
410</pre>
411
412<p>Use <kbd>-</kbd> as the filename to method Read() to read from standard in or to method Write() to write to standard out:</p>
413
414<pre class="code">
415 binmode STDOUT;
416 $image-&gt;Write('png:-');
417</pre>
418
419<p>To read an image in the GIF format from a PERL filehandle, use:</p>
420
421<pre class="code">
422 $image = Image::Magick-&gt;new;
423 open(IMAGE, 'image.gif');
424 $image-&gt;Read(file=&gt;\*IMAGE);
425 close(IMAGE);
426</pre>
427
428<p>To write an image in the PNG format to a PERL filehandle, use:</p>
429
430<pre class="code">
431 $filename = "image.png";
432 open(IMAGE, ">$filename");
433 $image-&gt;Write(file=&gt;\*IMAGE, filename=&gt;$filename);
434 close(IMAGE);
435</pre>
436
cristycb03ed62009-12-11 21:30:51 +0000437<p>Note, reading from or writing to a Perl filehandle may fail under Windows due to different versions of the C-runtime libraries between ImageMagick and the ActiveState Perl distributions or if one of the DLL's is linked with the /MT option. See <a href="http://msdn.microsoft.com/en-us/library/ms235460.aspx">Potential Errors Passing CRT Objects Across DLL Boundaries</a> for an explanation.</p>
438
cristy3ed852e2009-09-05 21:47:34 +0000439<p>If <kbd>%0Nd, %0No, or %0Nx</kbd> appears in the filename, it is interpreted as a printf format specification and the specification is replaced with the specified decimal, octal, or hexadecimal encoding of the scene number. For example,</p>
440
441<pre class="text">
442 image%03d.miff
443</pre>
444
445<p>converts files image000.miff, image001.miff, etc.</p>
446
447<p>You can optionally add <i>Image</i> to any method name. For example, ReadImage() is an alias for method Read().</p>
448
449</div>
450
451<h2><a name="manipulate"></a>Manipulate an Image</h2>
452<div class="doc-section">
453
454<p>Once you create an image with, for example, method ReadImage() you may want to operate on it. Below is a list of all the image manipulations methods available to you with PerlMagick. There are <a href="../www/examples.html">examples</a> of select PerlMagick methods. Here is an example call to an image manipulation method:</p>
455
456<pre class="code">
457 $image-&gt;Crop(geometry=&gt;'100x100+10+20');
458 $image-&gt;[$x]-&gt;Frame("100x200");
459</pre>
460
461<p>And here is a list of other image manipulation methods you can call:</p>
462
463<table class="doc">
464<caption>Image Manipulation Methods</caption>
465<tbody>
466 <tr>
467 <th>Method</th>
468 <th style="width: 40%">Parameters</th>
469 <th style="width: 40%">Description</th>
470 </tr>
471
472 <tr>
473 <td valign="top">AdaptiveBlur</td>
474 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
475 <td valign="top">adaptively blur the image with a Gaussian operator of the given radius and standard deviation (sigma). Decrease the effect near edges.</td>
476 </tr>
477
478 <tr>
479 <td valign="top">AdaptiveResize</td>
480 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, filter=&gt;{Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, Sinc}, support=&gt;<i>double</i>, blur=&gt;<i>double</i></td>
481 <td valign="top">adaptively resize image using data dependant triangulation. Specify <kbd>blur</kbd> &gt; 1 for blurry or &lt; 1 for sharp</td>
482 </tr>
483
484 <tr>
485 <td valign="top">AdaptiveSharpen</td>
486 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
487 <td valign="top">adaptively sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma). Increase the effect near edges.</td>
488 </tr>
489
490 <tr>
491 <td valign="top">AdaptiveThreshold</td>
492 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, offset=&gt;<i>integer</i></td>
493 <td valign="top">local adaptive thresholding.</td>
494 </tr>
495
496 <tr>
497 <td valign="top">AddNoise</td>
498 <td valign="top">noise=&gt;{Uniform, Gaussian, Multiplicative, Impulse, Laplacian, Poisson}, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
499 <td valign="top">add noise to an image</td>
500 </tr>
501
502 <tr>
503 <td valign="top">AffineTransform</td>
504 <td valign="top">affine=&gt;<i>array of float values</i>, translate=&gt;<i>float, float</i>, scale=&gt; <i>float, float</i>, rotate=&gt;<i>float</i>, skewX=&gt;<i>float</i>, skewY=&gt;<i>float</i>, interpolate={Average, Bicubic, Bilinear, Filter, Integer, Mesh, NearestNeighbor}, background=&gt;<i><a href="../www/color.html">color name</a></i></td>
505 <td valign="top">affine transform image</td>
506 </tr>
507
508 <tr>
509 <td valign="top">Affinity</td>
510 <td valign="top">image=&gt;<i>image-handle</i>, method=&gt;{None, FloydSteinberg, Riemersma}</td>
511 <td valign="top">choose a particular set of colors from this image</td>
512 </tr>
513
514 <tr>
515 <td valign="top">Annotate</td>
cristybebec402010-04-23 19:19:08 +0000516 <td valign="top">text=&gt;<i>string</i>, font=&gt;<i>string</i>, family=&gt;<i>string</i>, style=&gt;{Normal, Italic, Oblique, Any}, stretch=&gt;{Normal, UltraCondensed, ExtraCondensed, Condensed, SemiCondensed, SemiExpanded, Expanded, ExtraExpanded, UltraExpanded}, weight=&gt;<i>integer</i>, pointsize=&gt;<i>integer</i>, density=&gt;<i>geometry</i>, stroke=&gt;<i><a href="../www/color.html">color name</a></i>, strokewidth=&gt;<i>integer</i>, fill=&gt;<i><a href="../www/color.html">color name</a></i>, undercolor=&gt;<i><a href="../www/color.html">color name</a></i>, kerning=&gt;<i>float</i>, geometry=&gt;<i>geometry</i>, gravity=&gt;{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, antialias=&gt;{true, false}, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, affine=&gt;<i>array of float values</i>, translate=&gt;<i>float, float</i>, scale=&gt;<i>float, float</i>, rotate=&gt;<i>float</i>. skewX=&gt;<i>float</i>, skewY=&gt; <i>float</i>, align=&gt;{Left, Center, Right}, encoding=&gt;{UTF-8}, interline-spacing=&gt;<i>double</i>, interword-spacing=&gt;<i>double</i>, direction=&gt;{right-to-left, left-to-right}</td>
cristy3ed852e2009-09-05 21:47:34 +0000517 <td valign="top">annotate an image with text. See <a href="#misc">QueryFontMetrics</a> to get font metrics without rendering any text.</td>
518 </tr>
519
520 <tr>
521 <td valign="top">AutoGamma</td>
522 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
523 <td valign="top">automagically adjust gamma level of image</td>
524 </tr>
525
526 <tr>
527 <td valign="top">AutoLevel</td>
528 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
529 <td valign="top">automagically adjust color levels of image</td>
530 </tr>
531
532 <tr>
533 <td valign="top">AutoOrient</td>
534 <td valign="top"><br /></td>
535 <td valign="top">automagically orient the image</td>
536 </tr>
537
538 <tr>
539 <td valign="top">BlackThreshold</td>
cristyec407392009-11-28 22:42:05 +0000540 <td valign="top">threshold=&gt;<i>string</i>, , channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
cristy3ed852e2009-09-05 21:47:34 +0000541 <td valign="top">force all pixels below the threshold intensity into black</td>
542 </tr>
543
544 <tr>
545 <td valign="top">BlueShift</td>
546 <td valign="top">factor=&gt;<i>double</i>,</td>
547 <td valign="top">simulate a scene at nighttime in the moonlight. Start with a factor of 1.5.</td>
548 </tr>
549
550 <tr>
551 <td valign="top">Blur</td>
552 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
553 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td>
554 </tr>
555
556 <tr>
557 <td valign="top">Border</td>
558 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, bordercolor=&gt;<i><a href="../www/color.html">color name</a></i>, compose=&gt;{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, RGB, CopyYellow, Darken, Dst, Difference, Displace, Dissolve, DstAtop, DstIn, DstOut, DstOver, Dst, Exclusion, HardLight, Hue, In, Lighten, Luminize, Minus, Modulate, Multiply, None, Out, Overlay, Over, Plus, ReplaceCompositeOp, Saturate, Screen, SoftLight, Src, SrcAtop, SrcIn, SrcOut, SrcOver, Src, Subtract, Threshold, Xor },</td>
559 <td valign="top">surround the image with a border of color</td>
560 </tr>
561
562 <tr>
563 <td valign="top">Charcoal</td>
564 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i></td>
565 <td valign="top">simulate a charcoal drawing</td>
566 </tr>
567
568 <tr>
569 <td valign="top">Chop</td>
570 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
571 <td valign="top">chop an image</td>
572 </tr>
573
574 <tr>
cristyb4c03bb2009-09-27 13:55:46 +0000575 <td valign="top">Clamp</td>
576 <td valign="top"><br /></td>
577 <td valign="top">restrict color values from 0 to the quantum depth.</td>
578 </tr>
579
580 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000581 <td valign="top">Clip</td>
582 <td valign="top">id=&gt;<i>name</i>, inside=&gt;<i>{true, false}</i>,</td>
583 <td valign="top">apply along a named path from the 8BIM profile.</td>
584 </tr>
585
586 <tr>
587 <td valign="top">ClipMask</td>
588 <td valign="top">mask=&gt;<i>image-handle</i></td>
589 <td valign="top">clip image as defined by the image mask</td>
590 </tr>
591
592 <tr>
593 <td valign="top">Clut</td>
594 <td valign="top">image=&gt;<i>image-handle</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
595 <td valign="top">apply a color lookup table to an image sequence</td>
596 </tr>
597
598 <tr>
599 <td valign="top">Coalesce</td>
600 <td valign="top"><br /></td>
601 <td valign="top">merge a sequence of images</td>
602 </tr>
603
604 <tr>
cristy83a272e2010-05-07 20:40:35 +0000605 <td valign="top">Color</td>
606 <td valign="top">color=&gt;<i><a href="../www/color.html">color name</a></i></td>
607 <td valign="top">set the entire image to this color.</td>
608 </tr>
609
610 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000611 <td valign="top">ColorDecisionList</td>
612 <td valign="top">filename=&gt;<i>string</i>,</td>
613 <td valign="top">color correct with a color decision list.</td>
614 </tr>
615
616 <tr>
617 <td valign="top">Colorize</td>
618 <td valign="top">fill=&gt;<i><a href="../www/color.html">color name</a></i>, opacity=&gt;<i>string</i></td>
619 <td valign="top">colorize the image with the fill color</td>
620 </tr>
621
622 <tr>
cristy2c839602010-04-03 02:32:08 +0000623 <td valign="top">ColorMatrix</td>
624 <td valign="top">matrix=&gt;<i>array of float values</i></td>
625 <td valign="top">apply color correction to the image. Although you can use variable sized matrices, typically you use a 5 x 5 for an RGBA image and a 6x6 for CMYKA. A 6x6 matrix is required for offsets (populate the last column with normalized values).</td>
626 </tr>
627
628 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000629 <td valign="top">Comment</td>
630 <td valign="top">string</td>
631 <td valign="top">add a comment to your image</td>
632 </tr>
633
634 <tr>
635 <td valign="top">CompareLayers</td>
636 <td valign="top">method=&gt;{any, clear, overlay}</td>
637 <td valign="top">compares each image with the next in a sequence and returns the minimum bounding region of any pixel differences it discovers. Images do not have to be the same size, though it is best that all the images are coalesced (images are all the same size, on a flattened canvas, so as to represent exactly how a specific frame should look).</td>
638 </tr>
639
640 <tr>
641 <td valign="top">Composite</td>
642 <td valign="top">image=&gt;<i>image-handle</i>, compose=&gt;{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, RGB, CopyYellow, Darken, Dst, Difference, Displace, Dissolve, DstAtop, DstIn, DstOut, DstOver, Dst, Exclusion, HardLight, Hue, In, Lighten, Luminize, Minus, Modulate, Multiply, None, Out, Overlay, Over, Plus, ReplaceCompositeOp, Saturate, Screen, SoftLight, Src, SrcAtop, SrcIn, SrcOut, SrcOver, Src, Subtract, Threshold, Xor }, mask=&gt;<i>image-handle</i>, geometry=&gt;<i>geometry</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, gravity=&gt;{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, opacity=&gt;<i>integer</i>, tile=&gt;{True, False}, rotate=&gt;<i>double</i>, color=&gt;<i><a href="../www/color.html">color name</a></i>, blend=&gt;<i>geometry</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, filter, integer, mesh, nearest-neighbor, spline}</td>
643 <td valign="top">composite one image onto another. Use the rotate parameter in concert with the tile parameter.</td>
644 </tr>
645
646 <tr>
647 <td valign="top">Contrast</td>
648 <td valign="top">sharpen=&gt;{True, False}</td>
649 <td valign="top">enhance or reduce the image contrast</td>
650 </tr>
651
652 <tr>
653 <td valign="top">ContrastStretch</td>
654 <td valign="top">levels=&gt;<i>string</i>, 'black-point'=&gt;<i>double</i>, 'white-point'=&gt;<i>double</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
655 <td valign="top">improve the contrast in an image by `stretching' the range of intensity values</td>
656 </tr>
657
658 <tr>
659 <td valign="top">Convolve</td>
cristy16ff93c2010-01-13 23:18:07 +0000660 <td valign="top">coefficients=&gt;<i>array of float values</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, bias=&gt;<i>double</i></td>
cristy3ed852e2009-09-05 21:47:34 +0000661 <td valign="top">apply a convolution kernel to the image. Given a kernel <i>order</i> , you would supply <i>order*order</i> float values (e.g. 3x3 implies 9 values).</td>
662 </tr>
663
664 <tr>
665 <td valign="top">Crop</td>
cristya13871a2009-12-06 19:01:22 +0000666 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, fuzz=&gt;<i>double</i>, gravity=&gt;{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
cristy3ed852e2009-09-05 21:47:34 +0000667 <td valign="top">crop an image</td>
668 </tr>
669
670 <tr>
671 <td valign="top">CycleColormap</td>
672 <td valign="top">amount=&gt;<i>integer</i></td>
673 <td valign="top">displace image colormap by amount</td>
674 </tr>
675
676 <tr>
677 <td valign="top">Decipher</td>
678 <td valign="top">passphrase=&gt;<i>string</i></td>
679 <td valign="top">convert cipher pixels to plain pixels</td>
680 </tr>
681
682 <tr>
683 <td valign="top">Deconstruct</td>
684 <td valign="top"><br /></td>
685 <td valign="top">break down an image sequence into constituent parts</td>
686 </tr>
687
688 <tr>
689 <td valign="top">Deskew</td>
690 <td valign="top">geometry=&gt;<i>string</i>,threshold=&gt;<i>double</i></td>
691 <td valign="top">straighten the image</td>
692 </tr>
693
694 <tr>
695 <td valign="top">Despeckle</td>
696 <td valign="top">&nbsp;</td>
697 <td valign="top">reduce the speckles within an image</td>
698 </tr>
699
700 <tr>
701 <td valign="top">Difference</td>
702 <td valign="top">image=&gt;<i>image-handle</i></td>
703 <td valign="top">compute the difference metrics between two images </td>
704 </tr>
705
706 <tr>
707 <td valign="top">Distort</td>
708 <td valign="top">points=&gt;<i>array of float values</i>, method=&gt;{Affine, AffineProjection, Bilinear, Perspective, ScaleRotateTranslate}, virtual-pixel=&gt;{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}, best-fit=&gt;{True, False}</td>
709 <td valign="top">distort image</td>
710 </tr>
711
712 <tr>
713 <td valign="top">Draw</td>
cristybebec402010-04-23 19:19:08 +0000714 <td valign="top">primitive=&gt;{point, line, rectangle, arc, ellipse, circle, path, polyline, polygon, bezier, color, matte, text, @<i>filename</i>}, points=&gt;<i>string</i> , method=&gt;<i>{Point, Replace, Floodfill, FillToBorder, Reset}</i>, stroke=&gt;<i><a href="../www/color.html">color name</a></i>, fill=&gt;<i><a href="../www/color.html">color name</a></i>, font=&gt;<i>string</i>, pointsize=&gt;<i>integer</i>, strokewidth=&gt;<i>float</i>, antialias=&gt;{true, false}, bordercolor=&gt;<i><a href="../www/color.html">color name</a></i>, x=&gt;<i>float</i>, y=&gt;<i>float</i>, dash-offset=&gt;<i>float</i>, dash-pattern=&gt;<i>array of float values</i>, affine=&gt;<i>array of float values</i>, translate=&gt;<i>float, float</i>, scale=&gt;<i>float, float</i>, rotate=&gt;<i>float</i>, skewX=&gt;<i>float</i>, skewY=&gt;<i>float</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}, kerning=&gt;<i>float</i>, text=&gt;<i>string</i>, vector-graphics=&gt;<i>string</i>, interline-spacing=&gt;<i>double</i>, interword-spacing=&gt;<i>double</i>, direction=&gt;{right-to-left, left-to-right}</td>
cristy3ed852e2009-09-05 21:47:34 +0000715 <td valign="top">annotate an image with one or more graphic primitives.</td>
716 </tr>
717
718 <tr>
719 <td valign="top">Encipher</td>
720 <td valign="top">passphrase=&gt;<i>string</i></td>
721 <td valign="top">convert plain pixels to cipher pixels</td>
722 </tr>
723
724 <tr>
725 <td valign="top">Edge</td>
726 <td valign="top">radius=&gt;<i>double</i></td>
727 <td valign="top">enhance edges within the image with a convolution filter of the given radius.</td>
728 </tr>
729
730 <tr>
731 <td valign="top">Emboss</td>
732 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i></td>
733 <td valign="top">emboss the image with a convolution filter of the given radius and standard deviation (sigma).</td>
734 </tr>
735
736 <tr>
737 <td valign="top">Enhance</td>
738 <td valign="top"><br /></td>
739 <td valign="top">apply a digital filter to enhance a noisy image</td>
740 </tr>
741
742 <tr>
743 <td valign="top">Equalize</td>
744 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}<br /></td>
745 <td valign="top">perform histogram equalization to the image</td>
746 </tr>
747
748 <tr>
749 <td valign="top">Extent</td>
750 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, fuzz=&gt;<i>double</i>, background=&gt;<i><a href="../www/color.html">color name</a></i>, gravity=&gt;{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
751 <td valign="top">set the image size</td>
752 </tr>
753
754 <tr>
755 <td valign="top">Evaluate</td>
756 <td valign="top">value=&gt;<i>double</i>, operator=&gt;<i>{Add, And, Divide, LeftShift, Max, Min, Multiply, Or, Rightshift, Subtract, Xor}</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow} </td>
757 <td valign="top">apply an arithmetic, relational, or logical expression to the image</td>
758 </tr>
759
760 <tr>
cristy16ff93c2010-01-13 23:18:07 +0000761 <td valign="top">Filter</td>
762 <td valign="top">kernel=&gt;<i>string</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, bias=&gt;<i>double</i></td>
763 <td valign="top">apply a convolution kernel to the image.</td>
764 </tr>
765
766 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000767 <td valign="top">Flip</td>
768 <td valign="top"><br /></td>
769 <td valign="top">reflect the image scanlines in the vertical direction</td>
770 </tr>
771
772 <tr>
773 <td valign="top">Flop</td>
774 <td valign="top"><br /></td>
775 <td valign="top">reflect the image scanlines in the horizontal direction</td>
776 </tr>
777
778 <tr>
779 <td valign="top">FloodfillPaint</td>
780 <td valign="top">geometry=&gt;<i>geometry</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, x=&gt;<i>integer</i>, y=&gt;<i>integer</i> , fill=&gt;<i><a href="../www/color.html">color name</a></i>, bordercolor=&gt;<i><a href="../www/color.html">color name</a></i>, fuzz=&gt;<i>double</i>, invert=&gt;{True, False}</td>
781 <td valign="top">changes the color value of any pixel that matches the color of the target pixel and is a neighbor. If you specify a border color, the color value is changed for any neighbor pixel that is not that color.</td>
782 </tr>
783
784 <tr>
785 <td valign="top">ForwardFourierTransform</td>
786 <td valign="top">magnitude=&gt;{True, False}</td>
787 <td valign="top">implements the forward discrete Fourier transform (DFT)</td>
788 </tr>
789
790 <tr>
791 <td valign="top">Frame</td>
792 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, inner=&gt;<i>integer</i>, outer=&gt;<i>integer</i>, fill=&gt;<i><a href="../www/color.html">color name</a></i>, compose=&gt;{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, RGB, CopyYellow, Darken, Dst, Difference, Displace, Dissolve, DstAtop, DstIn, DstOut, DstOver, Dst, Exclusion, HardLight, Hue, In, Lighten, Luminize, Minus, Modulate, Multiply, None, Out, Overlay, Over, Plus, ReplaceCompositeOp, Saturate, Screen, SoftLight, Src, SrcAtop, SrcIn, SrcOut, SrcOver, Src, Subtract, Threshold, Xor },</td>
793 <td valign="top">surround the image with an ornamental border</td>
794 </tr>
795
796 <tr>
797 <td valign="top">Function</td>
798 <td valign="top">parameters=&gt;<i>array of float values</i>, function=&gt;{Sin}, virtual-pixel=&gt;{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
799 <td valign="top">apply a function to the image</td>
800 </tr>
801
802 <tr>
803 <td valign="top">Gamma</td>
804 <td valign="top">gamma=&gt;<i>string</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
805 <td valign="top">gamma correct the image</td>
806 </tr>
807
808 <tr>
809 <td valign="top">GaussianBlur</td>
810 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
811 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td>
812 </tr>
813
814 <tr>
815 <td valign="top">GetPixel</td>
816 <td valign="top">geometry=&gt;<i>geometry</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, normalize=&gt;{true, false}, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
817 <td valign="top">get a single pixel. By default normalized pixel values are returned.</td>
818 </tr>
819
820 <tr>
821 <td valign="top">GetPixels</td>
822 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, map=&gt;<i>string</i>, normalize=&gt;{true, false}</td>
823 <td valign="top">get image pixels as defined by the map (e.g. "RGB", "RGBA", etc.). By default non-normalized pixel values are returned.</td>
824 </tr>
825
826 <tr>
827 <td valign="top">HaldClut</td>
828 <td valign="top">image=&gt;<i>image-handle</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
829 <td valign="top">apply a Hald color lookup table to an image sequence</td>
830 </tr>
831
832 <tr>
833 <td valign="top">Identify</td>
cristy045bd902010-01-30 18:56:24 +0000834 <td valign="top">file=&gt;<i>file</i>, features=&gt;<i>distance</i>, unique=&gt;{True, False}</td>
cristy3ed852e2009-09-05 21:47:34 +0000835 <td valign="top">identify the attributes of an image</td>
836 </tr>
837
838 <tr>
839 <td valign="top">Implode</td>
840 <td valign="top">amount=&gt;<i>double</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
841 <td valign="top">implode image pixels about the center</td>
842 </tr>
843
844 <tr>
845 <td valign="top">InverseDiscreteFourierTransform</td>
846 <td valign="top">magnitude=&gt;{True, False}</td>
847 <td valign="top">implements the inverse discrete Fourier transform (DFT)</td>
848 </tr>
849
850 <tr>
851 <td valign="top">Label</td>
852 <td valign="top">string</td>
853 <td valign="top">assign a label to an image</td>
854 </tr>
855
856 <tr>
857 <td valign="top">Layers</td>
858 <td valign="top">method=&gt;{coalesce, compare-any, compare-clear, compare-over, composite, dispose, flatten, merge, mosaic, optimize, optimize-image, optimize-plus, optimize-trans, remove-dups, remove-zero}, compose=&gt;{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, RGB, CopyYellow, Darken, Dst, Difference, Displace, Dissolve, DstAtop, DstIn, DstOut, DstOver, Dst, Exclusion, HardLight, Hue, In, Lighten, LinearLight, Luminize, Minus, Modulate, Multiply, None, Out, Overlay, Over, Plus, ReplaceCompositeOp, Saturate, Screen, SoftLight, Src, SrcAtop, SrcIn, SrcOut, SrcOver, Src, Subtract, Threshold, Xor }, dither=&gt;{true, false}</td>
859 <td valign="top">compare each image the GIF disposed forms of the previous image in the sequence. From this, attempt to select the smallest cropped image to replace each frame, while preserving the results of the animation.</td>
860 </tr>
861
862 <tr>
863 <td valign="top">Level</td>
864 <td valign="top">levels=&gt;<i>string</i>, 'black-point'=&gt;<i>double</i>, 'gamma'=&gt;<i>double</i>, 'white-point'=&gt;<i>double</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
865 <td valign="top">adjust the level of image contrast</td>
866 </tr>
867
868 <tr>
cristye7f8fdd2009-09-20 14:43:12 +0000869 <td valign="top">LevelColors</td>
870 <td valign="top">invert=&gt;&gt;{True, False}, 'black-point'=&gt;<i>string</i>, 'white-point'=&gt;<i>string</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
871 <td valign="top">level image with the given colors</td>
872 </tr>
873
874 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000875 <td valign="top">LinearStretch</td>
876 <td valign="top">levels=&gt;<i>string</i>, 'black-point'=&gt;<i>double</i>, 'white-point'=&gt;<i>double</i></td>
877 <td valign="top">linear with saturation stretch</td>
878 </tr>
879
880 <tr>
881 <td valign="top">LiquidResize</td>
882 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, delta-x=&gt;<i>double</i>, rigidity=&gt;<i>double</i></td>
883 <td valign="top">rescale image with seam-carving.</td>
884 </tr>
885
886 <tr>
887 <td valign="top">Magnify</td>
888 <td valign="top"><br /></td>
889 <td valign="top">double the size of an image</td>
890 </tr>
891
892 <tr>
893 <td valign="top">Mask</td>
894 <td valign="top">mask=&gt;<i>image-handle</i></td>
895 <td valign="top">composite image pixels as defined by the mask</td>
896 </tr>
897
898 <tr>
899 <td valign="top">MatteFloodfill</td>
900 <td valign="top">geometry=&gt;<i>geometry</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i> , matte=&gt;<i>integer</i>, bordercolor=&gt;<i><a href="../www/color.html">color name</a></i>, fuzz=&gt;<i>double</i>, invert=&gt;{True, False}</td>
901 <td valign="top">changes the matte value of any pixel that matches the color of the target pixel and is a neighbor. If you specify a border color, the matte value is changed for any neighbor pixel that is not that color.</td>
902 </tr>
903
904 <tr>
905 <td valign="top">MedianFilter</td>
906 <td valign="top">radius=&gt;<i>double</i></td>
907 <td valign="top">replace each pixel with the median intensity pixel of a neighborhood.</td>
908 </tr>
909
910 <tr>
911 <td valign="top">Minify</td>
912 <td valign="top"><br /></td>
913 <td valign="top">half the size of an image</td>
914 </tr>
915
916 <tr>
917 <td valign="top">Modulate</td>
918 <td valign="top">brightness=&gt;<i>double</i>, saturation=&gt;<i>double</i>, hue=&gt;<i>double</i>, lightness=&gt;<i>double</i>, whiteness=&gt;<i>double</i>, blackness=&gt;<i>double</i> </td>
919 <td valign="top">vary the brightness, saturation, and hue of an image by the specified percentage</td>
920 </tr>
921
922 <tr>
cristy488844c2010-01-22 14:02:05 +0000923 <td valign="top">Morphology</td>
924 <td valign="top">kernel=&gt;<i>string</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, iterations=&gt;<i>integer</i></td>
925 <td valign="top">apply a morphology method to the image.</td>
926 </tr>
927
928 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000929 <td valign="top">MotionBlur</td>
930 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, angle=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
931 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma) at the given angle to simulate the effect of motion</td>
932 </tr>
933
934 <tr>
935 <td valign="top">Negate</td>
936 <td valign="top">gray=&gt;{True, False}, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
cristyb29bc032010-02-01 20:29:43 +0000937 <td valign="top">replace each pixel with its complementary color (white becomes black, yellow becomes blue, etc.)</td>
cristy3ed852e2009-09-05 21:47:34 +0000938 </tr>
939
940 <tr>
941 <td valign="top">Normalize</td>
942 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}<br /></td>
943 <td valign="top">transform image to span the full range of color values</td>
944 </tr>
945
946 <tr>
947 <td valign="top">OilPaint</td>
948 <td valign="top">radius=&gt;<i>integer</i></td>
949 <td valign="top">simulate an oil painting</td>
950 </tr>
951
952 <tr>
953 <td valign="top">Opaque</td>
954 <td valign="top">color=&gt;<i><a href="../www/color.html">color name</a></i>,
955fill=&gt;<i><a href="../www/color.html">color name</a></i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, invert=&gt;{True, False}</td>
956 <td valign="top">change this color to the fill color within the image</td>
957 </tr>
958
959 <tr>
960 <td valign="top">OrderedDither</td>
961 <td valign="top">threshold=&gt;{threshold, checks, o2x2, o3x3, o4x4, o8x8, h4x4a, h6x6a, h8x8a, h4x4o, h6x6o, h8x8o, h16x16o, hlines6x4}, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
962 <td valign="top">order dither image</td>
963 </tr>
964
965 <tr>
966 <td valign="top">Polaroid</td>
967 <td valign="top">caption=&gt;<i>string</i>, angle=&gt;<i>double</i>, pointsize=&gt;<i>double</i>, font=&gt;<i>string</i>, stroke=&gt; <i><a href="../www/color.html">color name</a></i>, strokewidth=&gt;<i>integer</i>, fill=&gt;<i><a href="../www/color.html">color name</a></i>, gravity=&gt;{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, background=&gt;<i><a href="../www/color.html">color name</a></i></td>
968 <td valign="top">simulate a Polaroid picture.</td>
969 </tr>
970
971 <tr>
972 <td valign="top">Posterize</td>
973 <td valign="top">levels=&gt;<i>integer</i>, dither=&gt;{True, False}</td>
974 <td valign="top">reduce the image to a limited number of color level</td>
975 </tr>
976
977 <tr>
978 <td valign="top">Profile</td>
979 <td valign="top">name=&gt;<i>string</i>, profile=&gt;<i>blob</i>, rendering-intent=&gt;{Undefined, Saturation, Perceptual, Absolute, Relative}, black-point-compensation=&gt;{True, False}</td>
980 <td valign="top">add or remove ICC or IPTC image profile; name is formal name (e.g. ICC or filename; set profile to <kbd>''</kbd> to remove profile</td>
981 </tr>
982
983 <tr>
984 <td valign="top">Quantize</td>
985 <td valign="top">colors=&gt;<i>integer</i>, colorspace=&gt;{RGB, Gray, Transparent, OHTA, XYZ, YCbCr, YIQ, YPbPr, YUV, CMYK, sRGB, HSL, HSB}, treedepth=&gt; <i>integer</i>, dither=&gt;{True, False}, dither-method=&gt;{Riemersma, Floyd-Steinberg}, measure_error=&gt;{True, False}, global_colormap=&gt;{True, False}, transparent-color=&gt;<i>color</i></td>
986 <td valign="top">preferred number of colors in the image</td>
987 </tr>
988
989 <tr>
990 <td valign="top">RadialBlur</td>
991 <td valign="top">angle=&gt;<i>double</i></td>
992 <td valign="top">radial blur the image.</td>
993 </tr>
994
995 <tr>
996 <td valign="top">Raise</td>
997 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, raise=&gt;{True, False}</td>
998 <td valign="top">lighten or darken image edges to create a 3-D effect</td>
999 </tr>
1000
1001 <tr>
cristy3ed852e2009-09-05 21:47:34 +00001002 <td valign="top">ReduceNoise</td>
1003 <td valign="top">radius=&gt;<i>double</i></td>
1004 <td valign="top">reduce noise in the image with a noise peak elimination filter</td>
1005 </tr>
1006
1007 <tr>
1008 <td valign="top">Remap</td>
cristy8d724052009-11-24 20:52:07 +00001009 <td valign="top">image=&gt;<i>image-handle</i>, dither=&gt;{true, false}, dither-method=&gt;{Riemersma, Floyd-Steinberg}</td>
cristy3ed852e2009-09-05 21:47:34 +00001010 <td valign="top">replace the colors of an image with the closest color from a reference image.</td>
1011 </tr>
1012
1013 <tr>
1014 <td valign="top">Resample</td>
1015 <td valign="top">density=&gt;<i>geometry</i>, x=&gt;<i>double</i>, y=&gt;<i>double</i>, filter=&gt;{Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, Sinc}, support=&gt;<i>double</i></td>
1016 <td valign="top">resample image to desired resolution. Specify <kbd>blur</kbd> &gt; 1 for blurry or &lt; 1 for sharp</td>
1017 </tr>
1018
1019 <tr>
1020 <td valign="top">Resize</td>
1021 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, filter=&gt;{Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, Sinc}, support=&gt;<i>double</i>, blur=&gt;<i>double</i></td>
1022 <td valign="top">scale image to desired size. Specify <kbd>blur</kbd> &gt; 1 for blurry or &lt; 1 for sharp</td>
1023 </tr>
1024
1025 <tr>
1026 <td valign="top">Roll</td>
1027 <td valign="top">geometry=&gt;<i>geometry</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
1028 <td valign="top">roll an image vertically or horizontally</td>
1029 </tr>
1030
1031 <tr>
1032 <td valign="top">Rotate</td>
1033 <td valign="top">degrees=&gt;<i>double</i>, background=&gt;<i><a href="../www/color.html">color name</a></i></td>
1034 <td valign="top">rotate an image</td>
1035 </tr>
1036
1037 <tr>
1038 <td valign="top">Sample</td>
1039 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1040 <td valign="top">scale image with pixel sampling.</td>
1041 </tr>
1042
1043 <tr>
1044 <td valign="top">Scale</td>
1045 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1046 <td valign="top">scale image to desired size</td>
1047 </tr>
1048
1049 <tr>
1050 <td valign="top">Segment</td>
1051 <td valign="top">colorspace=&gt;{RGB, Gray, Transparent, OHTA, XYZ, YCbCr, YCC, YIQ, YPbPr, YUV, CMYK}, verbose={True, False}, cluster-threshold=&gt;<i>double</i>, smoothing-threshold=<i>double</i></td>
1052 <td valign="top">segment an image by analyzing the histograms of the color components and identifying units that are homogeneous</td>
1053 </tr>
1054
1055 <tr>
1056 <td valign="top">SelectiveBlur</td>
1057 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, threshold=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1058 <td valign="top">selectively blur pixels within a contrast threshold.</td>
1059 </tr>
1060 <tr>
1061 <td valign="top">Separate</td>
1062 <td valign="top">channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
1063 <td valign="top">separate a channel from the image into a grayscale image</td>
1064 </tr>
1065
1066 <tr>
1067 <td valign="top">Shade</td>
1068 <td valign="top">geometry=&gt;<i>geometry</i>, azimuth=&gt;<i>double</i>, elevation=&gt;<i>double</i>, gray=&gt;{true, false}</td>
1069 <td valign="top">shade the image using a distant light source</td>
1070 </tr>
1071
1072 <tr>
1073 <td valign="top">SetPixel</td>
1074 <td valign="top">geometry=&gt;<i>geometry</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, color=&gt;<i>array of float values</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, color=&gt;<i>array of float values</i></td>
1075 <td valign="top">set a single pixel. By default normalized pixel values are expected.</td>
1076 </tr>
1077
1078 <tr>
1079 <td valign="top">Shadow</td>
1080 <td valign="top">geometry=&gt;<i>geometry</i>, opacity=&gt;<i>double</i>, sigma=&gt;<i>double</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
1081 <td valign="top">simulate an image shadow</td>
1082 </tr>
1083
1084 <tr>
1085 <td valign="top">Sharpen</td>
1086 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1087 <td valign="top">sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma).</td>
1088 </tr>
1089
1090 <tr>
1091 <td valign="top">Shave</td>
1092 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1093 <td valign="top">shave pixels from the image edges</td>
1094 </tr>
1095
1096 <tr>
1097 <td valign="top">Shear</td>
1098 <td valign="top">geometry=&gt;<i>geometry</i>, x=&gt;<i>double</i>, y=&gt;<i>double</i> fill=&gt;<i><a href="../www/color.html">color name</a></i></td>
1099 <td valign="top">shear the image along the X or Y axis by a positive or negative shear angle</td>
1100 </tr>
1101
1102 <tr>
1103 <td valign="top">SigmoidalContrast</td>
1104 <td valign="top">geometry=&gt;<i>string</i>, 'contrast'=&gt;<i>double</i>, 'mid-point'=&gt;<i>double</i> channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}, sharpen=&gt;{True, False}</td>
1105 <td valign="top">sigmoidal non-lineraity contrast control. Increase the contrast of the image using a sigmoidal transfer function without saturating highlights or shadows. <em class="option">Contrast</em> indicates how much to increase the contrast (0 is none; 3 is typical; 20 is a lot); <em class="option">mid-point</em> indicates where midtones fall in the resultant image (0 is white; 50% is middle-gray; 100% is black). To decrease contrast, set sharpen to False.</td>
1106 </tr>
1107
1108 <tr>
1109 <td valign="top">Signature</td>
1110 <td valign="top"><br /></td>
1111 <td valign="top">generate an SHA-256 message digest for the image pixel stream</td>
1112 </tr>
1113
1114 <tr>
1115 <td valign="top">Sketch</td>
1116 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, angle=&gt;<i>double</i></td>
1117 <td valign="top">sketch the image with a Gaussian operator of the given radius and standard deviation (sigma) at the given angle</td>
1118 </tr>
1119
1120 <tr>
1121 <td valign="top">Solarize</td>
1122 <td valign="top">geometry=&gt;<i>string</i>,threshold=&gt;<i>double</i></td>
1123 <td valign="top">negate all pixels above the threshold level</td>
1124 </tr>
1125
1126 <tr>
1127 <td valign="top">SparseColor</td>
1128 <td valign="top">points=&gt;<i>array of float values</i>, method=&gt;{Barycentric, Bilinear, Shepards, Voronoi}, virtual-pixel=&gt;{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
1129 <td valign="top">interpolate the image colors around the supplied points</td>
1130 </tr>
1131
1132 <tr>
1133 <td valign="top">Splice</td>
1134 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, fuzz=&gt;<i>double</i>, background=&gt;<i><a href="../www/color.html">color name</a></i>, gravity=&gt;{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
1135 <td valign="top">splice an image</td>
1136 </tr>
1137
1138 <tr>
1139 <td valign="top">Spread</td>
1140 <td valign="top">radius=&gt;<i>double</i></td>
1141 <td valign="top">displace image pixels by a random amount</td>
1142 </tr>
1143
1144 <tr>
1145 <td valign="top">Stegano</td>
1146 <td valign="top">image=&gt;<i>image-handle</i>, offset=&gt;<i>integer</i></td>
1147 <td valign="top">hide a digital watermark within the image</td>
1148 </tr>
1149
1150 <tr>
1151 <td valign="top">Stereo</td>
1152 <td valign="top">image=&gt;<i>image-handle</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
1153 <td valign="top">composites two images and produces a single image that is the composite of a left and right image of a stereo pair</td>
1154 </tr>
1155
1156 <tr>
1157 <td valign="top">Strip</td>
1158 <td valign="top"><br /></td>
1159 <td valign="top">strip an image of all profiles and comments.</td>
1160 </tr>
1161
1162 <tr>
1163 <td valign="top">Swirl</td>
1164 <td valign="top">degrees=&gt;<i>double</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
1165 <td valign="top">swirl image pixels about the center</td>
1166 </tr>
1167
1168 <tr>
1169 <td valign="top">Texture</td>
1170 <td valign="top">texture=&gt;<i>image-handle</i></td>
1171 <td valign="top">name of texture to tile onto the image background</td>
1172 </tr>
1173
1174 <tr>
1175 <td valign="top">Thumbnail</td>
1176 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1177 <td valign="top">changes the size of an image to the given dimensions and removes any associated profiles.</td>
1178 </tr>
1179
1180 <tr>
1181 <td valign="top">Threshold</td>
1182 <td valign="top">threshold=&gt;<i>string</i>, channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1183 <td valign="top">threshold the image</td>
1184 </tr>
1185
1186 <tr>
1187 <td valign="top">Tint</td>
1188 <td valign="top">fill=&gt;<i><a href="../www/color.html">color name</a></i>, opacity=&gt;<i>string</i></td>
1189 <td valign="top">tint the image with the fill color.</td>
1190 </tr>
1191
1192 <tr>
1193 <td valign="top">Transparent</td>
1194 <td valign="top">color=&gt;<i><a href="../www/color.html">color name</a></i>, invert=&gt;{True, False}</td>
1195 <td valign="top">make this color transparent within the image</td>
1196 </tr>
1197
1198 <tr>
1199 <td valign="top">Transpose</td>
1200 <td valign="top"><br /></td>
1201 <td valign="top">flip image in the vertical direction and rotate 90 degrees</td>
1202 </tr>
1203
1204 <tr>
1205 <td valign="top">Transverse</td>
1206 <td valign="top"><br /></td>
1207 <td valign="top">flop image in the horizontal direction and rotate 270 degrees</td>
1208 </tr>
1209
1210 <tr>
1211 <td valign="top">Trim</td>
1212 <td valign="top"><br /></td>
1213 <td valign="top">remove edges that are the background color from the image</td>
1214 </tr>
1215
1216 <tr>
1217 <td valign="top">UnsharpMask</td>
1218 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, amount=&gt;<i>double</i>, threshold=&gt;<i>double</i></td>
1219 <td valign="top">sharpen the image with the unsharp mask algorithm.</td>
1220 </tr>
1221
1222 <tr>
1223 <td valign="top">Vignette</td>
1224 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i>, background=&gt;<i><a href="../www/color.html">color name</a></i></td>
1225 <td valign="top">offset the edges of the image in vignette style</td>
1226 </tr>
1227
1228 <tr>
1229 <td valign="top">Wave</td>
1230 <td valign="top">geometry=&gt;<i>geometry</i>, amplitude=&gt;<i>double</i>, wavelength=&gt;<i>double</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
1231 <td valign="top">alter an image along a sine wave</td>
1232 </tr>
1233
1234 <tr>
1235 <td valign="top">WhiteThreshold</td>
cristyec407392009-11-28 22:42:05 +00001236 <td valign="top">threshold=&gt;<i>string</i>, , channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
cristy3ed852e2009-09-05 21:47:34 +00001237 <td valign="top">force all pixels above the threshold intensity into white</td>
1238 </tr>
1239</tbody>
1240</table>
1241
1242<p>Note, that the <kbd>geometry</kbd> parameter is a short cut for the <kbd>width</kbd> and <kbd>height</kbd> parameters (e.g. <kbd>geometry=&gt;'106x80'</kbd> is equivalent to <kbd>width=&gt;106, height=&gt;80</kbd> ).</p>
1243
1244<p>You can specify <kbd>@filename</kbd> in both Annotate() and Draw(). This reads the text or graphic primitive instructions from a file on disk. For example,</p>
1245
1246<pre class="code">
1247 $image-&gt;Draw(fill=&gt;'red', primitive=&gt;'rectangle',
1248 points=&gt;'20,20 100,100 40,40 200,200 60,60 300,300');
1249</pre>
1250
1251<p>Is equivalent to</p>
1252
1253<pre class="code">
1254 $image-&gt;Draw(fill=&gt;'red', primitive=&gt;'@draw.txt');
1255</pre>
1256
1257<p>Where <kbd>draw.txt</kbd> is a file on disk that contains this:</p>
1258
1259<pre class="text">
1260 rectangle 20, 20 100, 100
1261 rectangle 40, 40 200, 200
1262 rectangle 60, 60 300, 300
1263</pre>
1264
1265<p>The <i>text</i> parameter for methods, Annotate(), Comment(), Draw(), and Label() can include the image filename, type, width, height, or other image attribute by embedding these special format characters:</p>
1266
1267<pre class="text">
1268 %b file size
1269 %c comment
1270 %d directory
1271 %e filename extension
1272 %f filename
1273 %g page geometry
1274 %h height
1275 %i input filename
1276 %k number of unique colors
1277 %l label
1278 %m magick
1279 %n number of scenes
1280 %o output filename
1281 %p page number
1282 %q quantum depth
1283 %r image class and colorspace
1284 %s scene number
1285 %t top of filename
1286 %u unique temporary filename
1287 %w width
1288 %x x resolution
1289 %y y resolution
1290 %z image depth
1291 %C image compression type
1292 %D image dispose method
1293 %H page height
1294 %Q image compression quality
1295 %T image delay
1296 %W page width
1297 %X page x offset
1298 %Y page y offset
1299 %@ bounding box
1300 %# signature
1301 %% a percent sign
1302 \n newline
1303 \r carriage return
1304</pre>
1305
1306<p>For example,</p>
1307
1308<pre class="code">
1309 text=&gt;"%m:%f %wx%h"
1310</pre>
1311
1312<p>produces an annotation of <b>MIFF:bird.miff 512x480</b> for an image titled <b>bird.miff</b> and whose width is 512 and height is 480.</p>
1313
1314<p>You can optionally add <i>Image</i> to any method name. For example, TrimImage() is an alias for method Trim().</p>
1315
1316<p>Most of the attributes listed above have an analog in <a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
1317
1318</div>
1319
1320<h2><a name="set-attribute"></a>Set an Image Attribute</h2>
1321<div class="doc-section">
1322
1323<p>Use method Set() to set an image attribute. For example,</p>
1324
1325<pre class="code">
1326 $image-&gt;Set(dither=&gt;'True');
1327 $image-&gt;[$x]-&gt;Set(delay=&gt;3);
1328</pre>
1329
1330<p>Where this example uses 'True' and this document says '{True, False}',
1331you can use the case-insensitive strings 'True' and 'False', or you
1332can use the integers 1 and 0.</p>
1333
1334<p>When you call Get() on a Boolean attribute, Image::Magick returns 1 or 0, not a string.</p>
1335
1336<p>And here is a list of all the image attributes you can set:</p>
1337
1338<table class="doc">
1339 <caption>Image Attributes</caption>
1340 <tbody>
1341 <tr>
1342 <th>Attribute</th>
1343 <th style="width: 40%">Values</th>
1344 <th style="width: 40%">Description</th>
1345 </tr>
1346
1347 <tr>
1348 <td valign="top">adjoin</td>
1349 <td valign="top">{True, False}</td>
1350 <td valign="top">join images into a single multi-image file</td>
1351 </tr>
1352
1353 <tr>
1354 <td valign="top">alpha</td>
1355 <td valign="top">{On, Off, Opaque, Transparent, Copy, Extract, Set}</td>
1356 <td valign="top">control of and special operations involving the alpha/matte channel</td>
1357 </tr>
1358
1359 <tr>
1360 <td valign="top">antialias</td>
1361 <td valign="top">{True, False}</td>
1362 <td valign="top">remove pixel aliasing</td>
1363 </tr>
1364
1365 <tr>
1366 <td valign="top">area-limit</td>
1367 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001368 <td valign="top">set pixel area resource limit.</td>
cristy3ed852e2009-09-05 21:47:34 +00001369 </tr>
1370
1371 <tr>
1372 <td valign="top">attenuate</td>
1373 <td valign="top"><i>double</i></td>
1374 <td valign="top">lessen (or intensify) when adding noise to an image.</td>
1375 </tr>
1376
1377 <tr>
1378 <td valign="top">authenticate</td>
1379 <td valign="top"><i>string</i></td>
1380 <td valign="top">decrypt image with this password.</td>
1381 </tr>
1382
1383 <tr>
1384 <td valign="top">background</td>
1385 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1386 <td valign="top">image background color</td>
1387 </tr>
1388
1389 <tr>
1390 <td valign="top">blue-primary</td>
1391 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1392 <td valign="top">chromaticity blue primary point (e.g. 0.15, 0.06)</td>
1393 </tr>
1394
1395 <tr>
1396 <td valign="top">bordercolor</td>
1397 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1398 <td valign="top">set the image border color</td>
1399 </tr>
1400
1401 <tr>
1402 <td valign="top">clip-mask</td>
1403 <td valign="top"><i>image</i></td>
1404 <td valign="top">associate a clip mask with the image.</td>
1405 </tr>
1406
1407 <tr>
1408 <td valign="top">colormap[<i>i</i>]</td>
1409 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1410 <td valign="top">color name (e.g. red) or hex value (e.g. #ccc) at position
1411<i>i</i></td>
1412 </tr>
1413
1414 <tr>
1415 <td valign="top">comment</td>
1416 <td valign="top"><i>string</i></td>
1417 <td valign="top">set the image comment</td>
1418 </tr>
1419
1420 <tr>
1421 <td valign="top">compression</td>
1422 <td valign="top">{None, BZip, Fax, Group4, JPEG, JPEG2000, LosslessJPEG, LZW, RLE, Zip}</td>
1423 <td valign="top">type of image compression</td>
1424 </tr>
1425
1426 <tr>
1427 <td valign="top">debug</td>
1428 <td valign="top">{All, Annotate, Blob, Cache, Coder, Configure, Deprecate, Draw, Exception, Locale, None, Resource, Transform, X11}</td>
1429 <td valign="top">display copious debugging information</td>
1430 </tr>
1431
1432 <tr>
1433 <td valign="top">delay</td>
1434 <td valign="top"><i>integer</i></td>
1435 <td valign="top">this many 1/100ths of a second must expire before displaying the next image in a sequence</td>
1436 </tr>
1437
1438 <tr>
1439 <td valign="top">density</td>
1440 <td valign="top"><i>geometry</i></td>
1441 <td valign="top">vertical and horizontal resolution in pixels of the image</td>
1442 </tr>
1443
1444 <tr>
1445 <td valign="top">depth</td>
1446 <td valign="top"><i>integer</i></td>
1447 <td valign="top">image depth</td>
1448 </tr>
1449
1450 <tr>
cristybebec402010-04-23 19:19:08 +00001451 <td valign="top">direction</td>
1452 <td valign="top"><i>{Undefined, right-to-left, left-to-right</i></td>
1453 <td valign="top">render text right-to-left or left-to-right</td>
1454 </tr>
1455
1456 <tr>
cristy3ed852e2009-09-05 21:47:34 +00001457 <td valign="top">disk-limit</td>
1458 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001459 <td valign="top">set disk resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +00001460 </tr>
1461
1462 <tr>
1463 <td valign="top">dispose</td>
1464 <td valign="top"><i>{Undefined, None, Background, Previous}</i></td>
1465 <td valign="top">layer disposal method</td>
1466 </tr>
1467
1468 <tr>
1469 <td valign="top">dither</td>
1470 <td valign="top">{True, False}</td>
1471 <td valign="top">apply error diffusion to the image</td>
1472 </tr>
1473
1474 <tr>
1475 <td valign="top">display</td>
1476 <td valign="top"><i>string</i></td>
1477 <td valign="top">specifies the X server to contact</td>
1478 </tr>
1479
1480 <tr>
1481 <td valign="top">extract</td>
1482 <td valign="top"><i>geometry</i></td>
1483 <td valign="top">extract area from image</td>
1484 </tr>
1485
1486 <tr>
1487 <td valign="top">file</td>
1488 <td valign="top"><i>filehandle</i></td>
1489 <td valign="top">set the image filehandle</td>
1490 </tr>
1491
1492 <tr>
1493 <td valign="top">filename</td>
1494 <td valign="top"><i>string</i></td>
1495 <td valign="top">set the image filename</td>
1496 </tr>
1497
1498 <tr>
1499 <td valign="top">fill</td>
1500 <td valign="top"><i>color</i></td>
1501 <td valign="top">The fill color paints any areas inside the outline of drawn shape.</td>
1502 </tr>
1503
1504 <tr>
1505 <td valign="top">font</td>
1506 <td valign="top"><i>string</i></td>
1507 <td valign="top">use this font when annotating the image with text</td>
1508 </tr>
1509
1510 <tr>
1511 <td valign="top">fuzz</td>
1512 <td valign="top"><i>integer</i></td>
1513 <td valign="top">colors within this distance are considered equal</td>
1514 </tr>
1515
1516 <tr>
1517 <td valign="top">gamma</td>
1518 <td valign="top"><i>double</i></td>
1519 <td valign="top">gamma level of the image</td>
1520 </tr>
1521
1522 <tr>
1523 <td valign="top">Gravity</td>
1524 <td valign="top">{Forget, NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
1525 <td valign="top">type of image gravity</td>
1526 </tr>
1527
1528 <tr>
1529 <td valign="top">green-primary</td>
1530 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1531 <td valign="top">chromaticity green primary point (e.g. 0.3, 0.6)</td>
1532 </tr>
1533
1534 <tr>
1535 <td valign="top">index[<i>x</i>, <i>y</i>]</td>
1536 <td valign="top"><i>string</i></td>
1537 <td valign="top">colormap index at position (<i>x</i>, <i>y</i>)</td>
1538 </tr>
1539
1540 <tr>
1541 <td valign="top">interlace</td>
1542 <td valign="top">{None, Line, Plane, Partition, JPEG, GIF, PNG}</td>
1543 <td valign="top">the type of interlacing scheme</td>
1544 </tr>
1545
1546 <tr>
1547 <td valign="top">iterations</td>
1548 <td valign="top"><i>integer</i></td>
1549 <td valign="top">add Netscape loop extension to your GIF animation</td>
1550 </tr>
1551
1552 <tr>
1553 <td valign="top">label</td>
1554 <td valign="top"><i>string</i></td>
1555 <td valign="top">set the image label</td>
1556 </tr>
1557
1558 <tr>
1559 <td valign="top">loop</td>
1560 <td valign="top"><i>integer</i></td>
1561 <td valign="top">add Netscape loop extension to your GIF animation</td>
1562 </tr>
1563
1564 <tr>
1565 <td valign="top">magick</td>
1566 <td valign="top"><i>string</i></td>
1567 <td valign="top">set the image format</td>
1568 </tr>
1569
1570 <tr>
1571 <td valign="top">map-limit</td>
1572 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001573 <td valign="top">set map resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +00001574 </tr>
1575
1576 <tr>
1577 <td valign="top">mask</td>
1578 <td valign="top"><i>image</i></td>
1579 <td valign="top">associate a mask with the image.</td>
1580 </tr>
1581
1582 <tr>
1583 <td valign="top">matte</td>
1584 <td valign="top">{True, False}</td>
1585 <td valign="top">enable the image matte channel</td>
1586 </tr>
1587
1588 <tr>
1589 <td valign="top">mattecolor</td>
1590 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1591 <td valign="top">set the image matte color</td>
1592 </tr>
1593
1594 <tr>
1595 <td valign="top">memory-limit</td>
1596 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001597 <td valign="top">set memory resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +00001598 </tr>
1599
1600 <tr>
1601 <td valign="top">monochrome</td>
1602 <td valign="top">{True, False}</td>
1603 <td valign="top">transform the image to black and white</td>
1604 </tr>
1605
1606 <tr>
1607 <td valign="top">option</td>
1608 <td valign="top"><i>string</i></td>
1609 <td valign="top">associate an option with an image format (e.g. option=&gt;'ps:imagemask'</td>
1610 </tr>
1611
1612 <tr>
1613 <td valign="top">orientation</td>
1614 <td valign="top">{top-left, top-right, bottom-right, bottom-left, left-top, right-top, right-bottom, left-bottom}</td>
1615 <td valign="top">image orientation</td>
1616 </tr>
1617
1618 <tr>
1619 <td valign="top">page</td>
1620 <td valign="top">{ Letter, Tabloid, Ledger, Legal, Statement, Executive, A3, A4, A5, B4, B5, Folio, Quarto, 10x14} or <i>geometry</i></td>
1621 <td valign="top">preferred size and location of an image canvas</td>
1622 </tr>
1623
1624 <tr>
1625 <td valign="top">pixel[<i>x</i>, <i>y</i>]</td>
1626 <td valign="top"><i>string</i></td>
1627 <td valign="top">hex value (e.g. #ccc) at position (<i>x</i>, <i>y</i>)</td>
1628 </tr>
1629
1630 <tr>
1631 <td valign="top">pointsize</td>
1632 <td valign="top"><i>integer</i></td>
1633 <td valign="top">pointsize of the Postscript or TrueType font</td>
1634 </tr>
1635
1636 <tr>
1637 <td valign="top">quality</td>
1638 <td valign="top"><i>integer</i></td>
1639 <td valign="top">JPEG/MIFF/PNG compression level</td>
1640 </tr>
1641
1642 <tr>
1643 <td valign="top">red-primary</td>
1644 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1645 <td valign="top">chromaticity red primary point (e.g. 0.64, 0.33)</td>
1646 </tr>
1647
1648 <tr>
1649 <td valign="top">sampling-factor</td>
1650 <td valign="top"><i>geometry</i></td>
1651 <td valign="top">horizontal and vertical sampling factor</td>
1652 </tr>
1653
1654 <tr>
1655 <td valign="top">scene</td>
1656 <td valign="top"><i>integer</i></td>
1657 <td valign="top">image scene number</td>
1658 </tr>
1659
1660 <tr>
1661 <td valign="top">server</td>
1662 <td valign="top"><i>string</i></td>
1663 <td valign="top">specifies the X server to contact</td>
1664 </tr>
1665
1666 <tr>
1667 <td valign="top">size</td>
1668 <td valign="top"><i>string</i></td>
1669 <td valign="top">width and height of a raw image</td>
1670 </tr>
1671
1672 <tr>
1673 <td valign="top">stroke</td>
1674 <td valign="top"><i>color</i></td>
1675 <td valign="top">The stroke color paints along the outline of a shape.</td>
1676 </tr>
1677
1678 <tr>
1679 <td valign="top">texture</td>
1680 <td valign="top"><i>string</i></td>
1681 <td valign="top">name of texture to tile onto the image background</td>
1682 </tr>
1683
1684 <tr>
1685 <td valign="top">tile-offset</td>
1686 <td valign="top"><i>geometry</i></td>
1687 <td valign="top">image tile offset</td>
1688 </tr>
1689
1690 <tr>
1691 <td valign="top">time-limit</td>
1692 <td valign="top"><i>integer</i></td>
1693 <td valign="top">set time resource limit in seconds</td>
1694 </tr>
1695
1696 <tr>
1697 <td valign="top">type</td>
cristyefb2bdb2010-11-20 19:35:22 +00001698 <td valign="top">{Bilevel, Grayscale, GrayscaleMatte, Palette, PaletteMatte, TrueColor, TrueColorMatte, ColorSeparation, ColorSeparationMatte}</td>
cristy3ed852e2009-09-05 21:47:34 +00001699 <td valign="top">image type</td>
1700 </tr>
1701
1702 <tr>
1703 <td valign="top">units</td>
1704 <td valign="top">{ Undefined, PixelsPerInch, PixelsPerCentimeter}</td>
1705 <td valign="top">units of image resolution</td>
1706 </tr>
1707
1708 <tr>
1709 <td valign="top">verbose</td>
1710 <td valign="top">{True, False}</td>
1711 <td valign="top">print detailed information about the image</td>
1712 </tr>
1713
1714 <tr>
1715 <td valign="top">virtual-pixel</td>
1716 <td valign="top">{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
1717 <td valign="top">the virtual pixel method</td>
1718 </tr>
1719
1720 <tr>
1721 <td valign="top">white-point</td>
1722 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1723 <td valign="top">chromaticity white point (e.g. 0.3127, 0.329)</td>
1724 </tr>
1725 </tbody>
1726</table>
1727
1728<p>Note, that the <kbd>geometry</kbd> parameter is a short cut for the <kbd>width</kbd> and <kbd>height</kbd> parameters (e.g. <kbd>geometry=&gt;'106x80'</kbd> is equivalent to <kbd>width=&gt;106, height=&gt;80</kbd>).</p>
1729
1730<p>SetAttribute() is an alias for method Set().</p>
1731
1732<p>Most of the attributes listed above have an analog in
1733<a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
1734
1735</div>
1736
1737<h2><a name="get-attribute"></a>Get an Image Attribute</h2>
1738<div class="doc-section">
1739
1740<p>Use method Get() to get an image attribute. For example,</p>
1741
1742<pre class="code">
1743 ($a, $b, $c) = $image-&gt;Get('colorspace', 'magick', 'adjoin');
1744 $width = $image-&gt;[3]-&gt;Get('columns');
1745</pre>
1746
1747<p>In addition to all the attributes listed in <a href="#set-attribute">Set an Image Attribute</a> , you can get these additional attributes:</p>
1748
1749<table class="doc">
1750 <caption>Image Attributes</caption>
1751 <tbody>
1752 <tr>
1753 <th>Attribute</th>
1754 <th>Values</th>
1755 <th style="width: 60%">Description</th>
1756 </tr>
1757
1758 <tr>
1759 <td valign="top">area</td>
1760 <td valign="top"><i>integer</i></td>
1761 <td valign="top">current area resource consumed</td>
1762 </tr>
1763
1764 <tr>
1765 <td valign="top">base-columns</td>
1766 <td valign="top"><i>integer</i></td>
1767 <td valign="top">base image width (before transformations)</td>
1768 </tr>
1769
1770 <tr>
1771 <td valign="top">base-filename</td>
1772 <td valign="top"><i>string</i></td>
1773 <td valign="top">base image filename (before transformations)</td>
1774 </tr>
1775
1776 <tr>
1777 <td valign="top">base-rows</td>
1778 <td valign="top"><i>integer</i></td>
1779 <td valign="top">base image height (before transformations)</td>
1780 </tr>
1781
1782 <tr>
1783 <td valign="top">class</td>
1784 <td valign="top">{Direct, Pseudo}</td>
1785 <td valign="top">image class</td>
1786 </tr>
1787
1788 <tr>
1789 <td valign="top">colors</td>
1790 <td valign="top"><i>integer</i></td>
1791 <td valign="top">number of unique colors in the image</td>
1792 </tr>
1793
1794 <tr>
1795 <td valign="top">columns</td>
1796 <td valign="top"><i>integer</i></td>
1797 <td valign="top">image width</td>
1798 </tr>
1799
1800 <tr>
1801 <td valign="top">copyright</td>
1802 <td valign="top"><i>string</i></td>
1803 <td valign="top">get PerlMagick's copyright</td>
1804 </tr>
1805
1806 <tr>
1807 <td valign="top">directory</td>
1808 <td valign="top"><i>string</i></td>
1809 <td valign="top">tile names from within an image montage</td>
1810 </tr>
1811
1812 <tr>
1813 <td valign="top">elapsed-time</td>
1814 <td valign="top"><i>double</i></td>
1815 <td valign="top">elapsed time in seconds since the image was created</td>
1816 </tr>
1817
1818 <tr>
1819 <td valign="top">error</td>
1820 <td valign="top"><i>double</i></td>
1821 <td valign="top">the mean error per pixel computed with methods Compare() or Quantize()</td>
1822 </tr>
1823
1824 <tr>
1825 <td valign="top">bounding-box</td>
1826 <td valign="top"><i>string</i></td>
1827 <td valign="top">image bounding box</td>
1828 </tr>
1829
1830 <tr>
1831 <td valign="top">disk</td>
1832 <td valign="top"><i>integer</i></td>
1833 <td valign="top">current disk resource consumed</td>
1834 </tr>
1835
1836 <tr>
1837 <td valign="top">filesize</td>
1838 <td valign="top"><i>integer</i></td>
1839 <td valign="top">number of bytes of the image on disk</td>
1840 </tr>
1841
1842 <tr>
1843 <td valign="top">format</td>
1844 <td valign="top"><i>string</i></td>
1845 <td valign="top">get the descriptive image format</td>
1846 </tr>
1847
1848 <tr>
1849 <td valign="top">geometry</td>
1850 <td valign="top"><i>string</i></td>
1851 <td valign="top">image geometry</td>
1852 </tr>
1853
1854 <tr>
1855 <td valign="top">height</td>
1856 <td valign="top"><i>integer</i></td>
1857 <td valign="top">the number of rows or height of an image</td>
1858 </tr>
1859
1860 <tr>
1861 <td valign="top">id</td>
1862 <td valign="top"><i>integer</i></td>
1863 <td valign="top">ImageMagick registry id</td>
1864 </tr>
1865
1866 <tr>
1867 <td valign="top">mean-error</td>
1868 <td valign="top"><i>double</i></td>
1869 <td valign="top">the normalized mean error per pixel computed with methods Compare() or Quantize()</td>
1870 </tr>
1871
1872 <tr>
1873 <td valign="top">map</td>
1874 <td valign="top"><i>integer</i></td>
1875 <td valign="top">current memory-mapped resource consumed</td>
1876 </tr>
1877
1878 <tr>
1879 <td valign="top">matte</td>
1880 <td valign="top">{True, False}</td>
1881 <td valign="top">whether or not the image has a matte channel</td>
1882 </tr>
1883
1884 <tr>
1885 <td valign="top">maximum-error</td>
1886 <td valign="top"><i>double</i></td>
1887 <td valign="top">the normalized max error per pixel computed with methods Compare() or Quantize()</td>
1888 </tr>
1889
1890 <tr>
1891 <td valign="top">memory</td>
1892 <td valign="top"><i>integer</i></td>
1893 <td valign="top">current memory resource consumed</td>
1894 </tr>
1895
1896 <tr>
1897 <td valign="top">mime</td>
1898 <td valign="top"><i>string</i></td>
1899 <td valign="top">MIME of the image format</td>
1900 </tr>
1901
1902 <tr>
1903 <td valign="top">montage</td>
1904 <td valign="top"><i>geometry</i></td>
1905 <td valign="top">tile size and offset within an image montage</td>
1906 </tr>
1907
1908 <tr>
1909 <td valign="top">page.x</td>
1910 <td valign="top"><i>integer</i></td>
1911 <td valign="top">x offset of image virtual canvas</td>
1912 </tr>
1913
1914 <tr>
1915 <td valign="top">page.y</td>
1916 <td valign="top"><i>integer</i></td>
1917 <td valign="top">y offset of image virtual canvas</td>
1918 </tr>
1919
1920 <tr>
1921 <td valign="top">rows</td>
1922 <td valign="top"><i>integer</i></td>
1923 <td valign="top">the number of rows or height of an image</td>
1924 </tr>
1925
1926 <tr>
1927 <td valign="top">signature</td>
1928 <td valign="top"><i>string</i></td>
1929 <td valign="top">SHA-256 message digest associated with the image pixel stream</td>
1930 </tr>
1931
1932 <tr>
1933 <td valign="top">taint</td>
1934 <td valign="top">{True, False}</td>
1935 <td valign="top">True if the image has been modified</td>
1936 </tr>
1937
1938 <tr>
1939 <td valign="top">total-ink-density</td>
1940 <td valign="top"><i>double</i></td>
1941 <td valign="top">returns the total ink density for a CMYK image</td>
1942 </tr>
1943
1944 <tr>
1945 <td valign="top">transparent-color</td>
1946 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1947 <td valign="top">set the image transparent color</td>
1948 </tr>
1949
1950 <tr>
1951 <td valign="top">user-time</td>
1952 <td valign="top"><i>double</i></td>
1953 <td valign="top">user time in seconds since the image was created</td>
1954 </tr>
1955
1956 <tr>
1957 <td valign="top">version</td>
1958 <td valign="top"><i>string</i></td>
1959 <td valign="top">get PerlMagick's version</td>
1960 </tr>
1961
1962 <tr>
1963 <td valign="top">width</td>
1964 <td valign="top"><i>integer</i></td>
1965 <td valign="top">the number of columns or width of an image</td>
1966 </tr>
1967
1968 <tr>
1969 <td valign="top">x-resolution</td>
1970 <td valign="top"><i>integer</i></td>
1971 <td valign="top">x resolution of the image</td>
1972 </tr>
1973
1974 <tr>
1975 <td valign="top">y-resolution</td>
1976 <td valign="top"><i>integer</i></td>
1977 <td valign="top">y resolution of the image</td>
1978 </tr>
1979 </tbody>
1980</table>
1981
1982<p>GetAttribute() is an alias for method Get().</p>
1983
1984<p>Most of the attributes listed above have an analog in
1985<a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
1986
1987</div>
1988
1989<h2><a name="compare"></a>Compare an Image to its Reconstruction</h2>
1990<div class="doc-section">
1991</div>
1992
1993<p>Mathematically and visually annotate the difference between an image and its reconstruction with the Compare() method. The method supports these parameters:</p>
1994
1995<table class="doc">
1996 <caption>Compare Parameters</caption>
1997 <tbody>
1998 <tr>
1999 <th>Parameter</th>
2000 <th style="width: 40%">Values</th>
2001 <th style="width: 40%">Description</th>
2002 </tr>
2003
2004 <tr>
2005 <td valign="top">channel</td>
2006 <td valign="top"><i>double</i></td>
2007 <td valign="top">select image channels, the default is all channels except alpha.</td>
2008 </tr>
2009
2010 <tr>
2011 <td valign="top">fuzz</td>
2012 <td valign="top"><i>double</i></td>
2013 <td valign="top">colors within this distance are considered equal</td>
2014 </tr>
2015
2016 <tr>
2017 <td valign="top">image</td>
2018 <td valign="top"><i>image-reference</i></td>
2019 <td valign="top">the image reconstruction</td>
2020 </tr>
2021
2022 <tr>
2023 <td valign="top">metric</td>
2024 <td valign="top">AE, MAE, MEPP, MSE, PAE, PSNR, RMSE</td>
2025 <td valign="top">measure differences between images with this metric</td>
2026 </tr>
2027 </tbody>
2028</table>
2029
2030<p>In this example, we compare the ImageMagick logo to a sharpened reconstruction:</p>
2031
2032<pre class="code">
2033 use Image::Magick;
2034
2035 $logo=Image::Magick->New();
2036 $logo->Read('logo:');
2037 $sharp=Image::Magick->New();
2038 $sharp->Read('logo:');
2039 $sharp->Sharpen('0x1');
2040 $difference=$logo->Compare(image=>$sharp, metric=>'rmse');
2041 print $difference->Get('error'), "\n";
2042 $difference->Display();
2043</pre>
2044
2045<p>In addition to the reported root mean squared error of around 0.024, a difference image is displayed so you can visually identify the difference between the images.</p>
2046
2047<h2><a name="montage"></a>Create an Image Montage</h2>
2048<div class="doc-section">
2049
2050<p>Use method Montage() to create a composite image by combining several separate images. The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile. For example,</p>
2051
2052<pre class="code">
2053 $image-&gt;Montage(geometry=&gt;'160x160', tile=&gt;'2x2', texture=&gt;'granite:');
2054</pre>
2055
2056<p>And here is a list of Montage() parameters you can set:</p>
2057
2058<table class="doc">
2059 <caption>Montage Parameters</caption>
2060 <tbody>
2061 <tr>
2062 <th>Parameter</th>
2063 <th style="width: 40%">Values</th>
2064 <th style="width: 40%">Description</th>
2065 </tr>
2066
2067 <tr>
2068 <td valign="top">background</td>
2069 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
2070 <td valign="top">background color name</td>
2071 </tr>
2072
2073 <tr>
2074 <td valign="top">border</td>
2075 <td valign="top"><i>integer</i></td>
2076 <td valign="top">image border width</td>
2077 </tr>
2078
2079 <tr>
2080 <td valign="top">filename</td>
2081 <td valign="top"><i>string</i></td>
2082 <td valign="top">name of montage image</td>
2083 </tr>
2084
2085 <tr>
2086 <td valign="top">fill</td>
2087 <td valign="top"><a href="../www/color.html">color name</a></td>
2088 <td valign="top">fill color for annotations</td>
2089 </tr>
2090
2091 <tr>
2092 <td valign="top">font</td>
2093 <td valign="top"><i>string</i></td>
2094 <td valign="top">X11 font name</td>
2095 </tr>
2096
2097 <tr>
2098 <td valign="top">frame</td>
2099 <td valign="top"><i>geometry</i></td>
2100 <td valign="top">surround the image with an ornamental border</td>
2101 </tr>
2102
2103 <tr>
2104 <td valign="top">geometry</td>
2105 <td valign="top"><i>geometry</i></td>
2106 <td valign="top">preferred tile and border size of each tile of the composite
2107image (e.g. 120x120+4+3>)</td>
2108 </tr>
2109
2110 <tr>
2111 <td valign="top">gravity</td>
2112 <td valign="top">NorthWest, North, NorthEast, West, Center, East, SouthWest,
2113South, SouthEast</td>
2114 <td valign="top">direction image gravitates to within a tile</td>
2115 </tr>
2116
2117 <tr>
2118 <td valign="top">label</td>
2119 <td valign="top"><i>string</i></td>
2120 <td valign="top">assign a label to an image</td>
2121 </tr>
2122
2123 <tr>
2124 <td valign="top">mode</td>
2125 <td valign="top">Frame, Unframe, Concatenate</td>
2126 <td valign="top">thumbnail framing options</td>
2127 </tr>
2128
2129 <tr>
2130 <td valign="top">pointsize</td>
2131 <td valign="top"><i>integer</i></td>
2132 <td valign="top">pointsize of the Postscript or TrueType font</td>
2133 </tr>
2134
2135 <tr>
2136 <td valign="top">shadow</td>
2137 <td valign="top">{True, False}</td>
2138 <td valign="top">add a shadow beneath a tile to simulate depth</td>
2139 </tr>
2140
2141 <tr>
2142 <td valign="top">stroke</td>
2143 <td valign="top"><a href="../www/color.html">color name</a></td>
2144 <td valign="top">stroke color for annotations</td>
2145 </tr>
2146
2147 <tr>
2148 <td valign="top">texture</td>
2149 <td valign="top"><i>string</i></td>
2150 <td valign="top">name of texture to tile onto the image background</td>
2151 </tr>
2152
2153 <tr>
2154 <td valign="top">tile</td>
2155 <td valign="top"><i>geometry</i></td>
2156 <td valign="top">the number of tiles per row and page (e.g. 6x4)</td>
2157 </tr>
2158
2159 <tr>
2160 <td valign="top">title</td>
2161 <td valign="top">string</td>
2162 <td valign="top">assign a title to the image montage</td>
2163 </tr>
2164
2165 <tr>
2166 <td valign="top">transparent</td>
2167 <td valign="top"><i>string</i></td>
2168 <td valign="top">make this color transparent within the image</td>
2169 </tr>
2170 </tbody>
2171</table>
2172
2173<p>Note, that the <kbd>geometry</kbd> parameter is a short cut for the <kbd>width</kbd> and <kbd>height</kbd> parameters (e.g. <kbd>geometry=&gt;'106x80'</kbd> is equivalent to <kbd>width=&gt;106, height=&gt;80</kbd>).</p>
2174
2175<p>MontageImage() is an alias for method Montage().</p>
2176
2177<p>Most of the attributes listed above have an analog in <a href="../www/montage.html">montage</a>. See the documentation for a more detailed description of these attributes.</p>
2178
2179</div>
2180
2181<h2><a name="blobs"></a>Working with Blobs</h2>
2182<div class="doc-section">
2183
2184<p>A blob contains data that directly represent a particular image
2185format in memory instead of on disk. PerlMagick supports
2186blobs in any of these image <a href="../www/formats.html">formats</a> and provides methods to convert a blob to or from a particular image format.</p>
2187
2188<table class="doc">
2189 <caption>Blob Methods</caption>
2190 <tbody>
2191 <tr>
2192 <th>Method</th>
2193 <th>Parameters</th>
2194 <th>Return Value</th>
2195 <th>Description</th>
2196 </tr>
2197
2198 <tr>
2199 <td valign="top">ImageToBlob</td>
2200 <td valign="top">any image <a href="#set-attribute">attribute</a></td>
2201 <td valign="top">an array of image data in the respective image format</td>
2202 <td valign="top">convert an image or image sequence to an array of blobs</td>
2203 </tr>
2204
2205 <tr>
2206 <td valign="top">BlobToImage</td>
2207 <td valign="top">one or more blobs</td>
2208 <td valign="top">the number of blobs converted to an image</td>
2209 <td valign="top">convert one or more blobs to an image</td>
2210 </tr>
2211 </tbody>
2212</table>
2213
2214<p>ImageToBlob() returns the image data in their respective formats. You can then print it, save it to an ODBC database, write it to a file, or pipe it to a display program:</p>
2215
2216<pre class="code">
2217 @blobs = $image-&gt;ImageToBlob();
2218 open(DISPLAY,"| display -") || die;
2219 binmode DISPLAY;
2220 print DISPLAY $blobs[0];
2221 close DISPLAY;
2222</pre>
2223
2224<p>Method BlobToImage() returns an image or image sequence converted from the supplied blob:</p>
2225
2226<pre class="code">
2227 @blob=$db-&gt;GetImage();
2228 $image=Image::Magick-&gt;new(magick=&gt;'jpg');
2229 $image-&gt;BlobToImage(@blob);
2230</pre>
2231
2232</div>
2233
2234<h2><a name="direct-access"></a>Direct-access to Image Pixels</h2>
2235<div class="doc-section">
2236
2237<p>Use these methods to obtain direct access to the image pixels:</p>
2238
2239<table class="doc">
2240<caption>Direct-access to Image Pixels</caption>
2241<tbody>
2242 <tr>
2243 <th>Method</th>
2244 <th>Parameters</th>
2245 <th style="width: 50%">Description</th>
2246 </tr>
2247
2248 <tr>
2249 <td valign="top">GetAuthenticPixels</td>
2250 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
2251 <td valign="top">return image pixels as a C pointer</td>
2252 </tr>
2253
2254 <tr>
2255 <td valign="top">GetVirtualPixels</td>
2256 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
2257 <td valign="top">return image pixels as a const C pointer</td>
2258 </tr>
2259
2260 <tr>
2261 <td valign="top">GetAuthenticIndexQueue</td>
cristy48dd1af2009-10-02 01:21:56 +00002262 <td valign="top"></td>
cristy3ed852e2009-09-05 21:47:34 +00002263 <td valign="top">return image indexes as a C pointer</td>
2264 </tr>
2265
2266 <tr>
2267 <td valign="top">GetVirtualIndexQueue</td>
cristy48dd1af2009-10-02 01:21:56 +00002268 <td valign="top"></td>
cristy3ed852e2009-09-05 21:47:34 +00002269 <td valign="top">return image indexes as a const C pointer</td>
2270 </tr>
2271
2272 <tr>
2273 <td valign="top">SyncAuthenticPixels</td>
2274 <td valign="top"></td>
2275 <td valign="top">sync image pixels to pixel cache</td>
2276 </tr>
2277
2278</tbody>
2279</table>
2280
2281</div>
2282
2283<h2><a name="miscellaneous"></a>Miscellaneous Methods</h2>
2284<div class="doc-section">
2285
2286<p>The Append() method append a set of images. For example,</p>
2287
2288<pre class="code">
2289 $p = $image-&gt;Append(stack=&gt;{true,false});
2290</pre>
2291
2292<p>appends all the images associated with object <kbd>$image</kbd>. By default, images are stacked left-to-right. Set <kbd>stack</kbd> to True to stack them top-to-bottom.</p>
2293
cristy3ed852e2009-09-05 21:47:34 +00002294<p>The Clone() method copies a set of images. For example,</p>
2295
2296<pre class="code">
2297 $q = $p-&gt;Clone();
2298</pre>
2299
2300<p>copies all the images from object <kbd>$p</kbd> to <kbd>$q</kbd>. You can use this method for single or multi-image sequences.</p>
2301
cristy63fed272010-03-07 19:08:45 +00002302<p>The EvaluateImages() method applies an arithemtic, logical or relational expression to a set of images. For example,</p>
2303
2304<pre class="code">
2305 $p = $image-&gt;EvaluateImages('mean');
2306</pre>
2307
2308<p>averages all the images associated with object <kbd>$image</kbd>.</p>
2309
cristy7396d882010-01-27 02:37:56 +00002310<p>The Features() method returns features for each channel in the image in each of four directions (horizontal, vertical, left and right diagonals) for the specified distance. The features include the angular second momentum, contrast, correlation, sum of squares: variance, inverse difference moment, sum average, sum varience, sum entropy, entropy, difference variance, difference entropy, information measures of correlation 1, information measures of correlation 2, and maximum correlation coefficient. Values in RGB, CMYK, RGBA, or CMYKA order (depending on the image type).</p>
2311
2312<pre class="code">
2313 @features = $image-&gt;Features(1);
2314</pre>
2315
2316<p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p>
2317
cristy3ed852e2009-09-05 21:47:34 +00002318<p>The Flatten() method flattens a set of images and returns it. For example,</p>
2319
2320<pre class="code">
2321 $p = $images-&gt;Flatten(background=&gt;'none');
2322 $p-&gt;Write('flatten.png');
2323</pre>
2324
2325<p>The sequence of images is replaced by a single image created by composing each image after the first over the first image.</p>
2326
2327<p>The Fx() method applies a mathematical expression to a set of images and returns the results. For example,</p>
2328
2329<pre class="code">
2330 $p = $image-&gt;Fx(expression=&gt;'(g+b)/2.0',channel=&gt;'red');
2331 $p-&gt;Write('fx.miff');
2332</pre>
2333
2334<p>replaces the red channel with the average of the green and blue channels.</p>
2335
2336<p>See <a href="../www/fx.html">FX, The Special Effects Image Operator</a> for a detailed discussion of this method.</p>
2337
2338<p>Histogram() returns the unique colors in the image and a count for each one. The returned values are an array of red, green, blue, opacity, and count values.</p>
2339
2340<p>The Morph() method morphs a set of images. Both the image pixels and size are linearly interpolated to give the appearance of a meta-morphosis from one image to the next:</p>
2341
2342<pre class="code">
2343 $p = $image-&gt;Morph(frames=&gt;<i>integer</i>);
2344</pre>
2345
2346<p>where <i>frames</i> is the number of in-between images to generate. The default is 1.</p>
2347
2348<p>Mosaic() creates an mosaic from an image sequence.</p>
2349
2350<p>Method Mogrify() is a single entry point for the image manipulation methods (<a href="#manipulate">Manipulate an Image</a>). The parameters are the name of a method followed by any parameters the method may require. For example, these calls are equivalent:</p>
2351
2352<pre class="code">
2353 $image-&gt;Crop('340x256+0+0');
2354 $image-&gt;Mogrify('crop', '340x256+0+0');
2355</pre>
2356
2357<p>Method MogrifyRegion() applies a transform to a region of the image. It is similar to Mogrify() but begins with the region geometry. For example, suppose you want to brighten a 100x100 region of your image at location (40, 50):</p>
2358
2359<pre class="code">
2360 $image-&gt;MogrifyRegion('100x100+40+50', 'modulate', brightness=&gt;50);
2361</pre>
2362
2363<p>Ping() is a convenience method that returns information about an image without having to read the image into memory. It returns the width, height, file size in bytes, and the file format of the image. You can specify more than one filename but only one filehandle:</p>
2364
2365<pre class="code">
2366 ($width, $height, $size, $format) = $image-&gt;Ping('logo.png');
2367 ($width, $height, $size, $format) = $image-&gt;Ping(file=&gt;\*IMAGE);
2368 ($width, $height, $size, $format) = $image-&gt;Ping(blob=&gt;$blob);
2369</pre>
2370
2371<p>This a more efficient and less memory intensive way to query if an image exists and what its characteristics are. <kbd>PreviewImage()</kbd> tiles 9 thumbnails of the specified image with an image processing operation applied at varying strengths. This may be helpful pin-pointing an appropriate parameter for a particular image processing operation. Choose from these operations: <kbd>Rotate, Shear, Roll, Hue, Saturation, Brightness, Gamma, Spiff, Dull, Grayscale, Quantize, Despeckle, ReduceNoise, AddNoise, Sharpen, Blur, Threshold, EdgeDetect, Spread, Solarize, Shade, Raise, Segment, Swirl, Implode, Wave, OilPaint, CharcoalDrawing, JPEG</kbd>. Here is an example:</p>
2372
2373<pre class="code">
2374 $preview = $image-&gt;Preview('Gamma');
2375 $preview-&gt;Display();
2376</pre>
2377
2378<p>To have full control over text positioning you need font metric information. Use</p>
2379
2380<pre class="code">
2381 ($x_ppem, $y_ppem, $ascender, $descender, $width, $height, $max_advance)
2382 = $image-&gt;QueryFontMetrics(<i>parameters</i>);
2383</pre>
2384
2385<p>Where <i>parameters</i> is any parameter of the <a href="#manipulate">Annotate</a> method. The return values are:</p>
2386
2387<ul>
2388 <li>character width</li>
2389 <li>character height</li>
2390 <li>ascender</li>
2391 <li>descender</li>
2392 <li>text width</li>
2393 <li>text height</li>
2394 <li>maximum horizontal advance</li>
2395 <li>bounds: x1</li>
2396 <li>bounds: y1</li>
2397 <li>bounds: x2</li>
2398 <li>bounds: y2</li>
2399 <li>origin: x</li>
2400 <li>origin: y</li>
2401</ul>
2402
2403<p>Use QueryMultilineFontMetrics() to get the maximum text width and height for multiple lines of text.</p>
2404
2405<p>Call QueryColor() with no parameters to return a list of known colors names or specify one or more color names to get these attributes: red, green, blue, and opacity value.</p>
2406
2407<pre class="code">
2408 @colors = $image-&gt;QueryColor();
2409 ($red, $green, $blue, $opacity) = $image-&gt;QueryColor('cyan');
2410 ($red, $green, $blue, $opacity) = $image-&gt;QueryColor('#716bae');
2411</pre>
2412
2413<p>QueryColorname() accepts a color value and returns its respective name or hex value;</p>
2414
2415<pre class="code">
2416 $name = $image-&gt;QueryColorname('rgba(80,60,0,0)');
2417</pre>
2418
2419<p>Call QueryFont() with no parameters to return a list of known fonts or specify one or more font names to get these attributes: font name, description, family, style, stretch, weight, encoding, foundry, format, metrics, and glyphs values.</p>
2420
2421<pre class="code">
2422 @fonts = $image-&gt;QueryFont();
2423 $weight = ($image-&gt;QueryFont('Helvetica'))[5];
2424</pre>
2425
2426<p>Call QueryFormat() with no parameters to return a list of known image formats or specify one or more format names to get these attributes: adjoin, blob support, raw, decoder, encoder, description, and module.</p>
2427
2428<pre class="code">
2429 @formats = $image-&gt;QueryFormat();
2430 ($adjoin, $blob_support, $raw, $decoder, $encoder, $description, $module)
2431 = $image-&gt;QueryFormat('gif');
2432</pre>
2433
2434<p>Call MagickToMime() with the image format name to get its MIME type such as <kbd>images/tiff</kbd> from <kbd>tif</kbd>.</p>
2435
2436<pre class="code">
2437 $mime = $image-&gt;MagickToMime('tif');
2438</pre>
2439
2440<p>Use RemoteCommand() to send a command to an already running <a href="../www/display.html">display</a> or <a href="../www/animate.html">animate</a> application. The only parameter is the name of the image file to display or animate.</p>
2441
2442<pre class="code">
2443 $image-&gt;RemoteCommand('image.jpg');
2444</pre>
2445
2446<p>Statistics() returns the image statistics for each channel in the image. The returned values are an array of depth, minima, maxima, mean, standard deviation, kurtosis, and skewness values in RGB, CMYK, RGBA, or CMYKA order (depending on the image type).</p>
2447
2448<pre class="code">
2449 @statistics = $image-&gt;Statistics();
2450</pre>
2451
2452<p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p>
2453
2454<pre class="code">
2455 $p = $image-&gt;Transform(crop=&gt;'100x100+0+0', gravity=&gt;'Center');
2456</pre>
2457
2458<p>You can optionally add <i>Image</i> to any method name above. For example, PingImage() is an alias for method Ping().</p>
2459
2460</div>
2461
2462<h2><a name="exceptions"></a>Handling Exceptions</h2>
2463<div class="doc-section">
2464
2465<p>All PerlMagick methods return an undefined string context upon success. If any problems occur, the error is returned as a string with an embedded numeric status code. A status code less than 400 is a warning. This means that the operation did not complete but was recoverable to some degree. A numeric code greater or equal to 400 is an error and indicates the operation failed completely. Here is how exceptions are returned for the different methods:</p>
2466
2467<p>Methods which return a number (e.g. Read(), Write()):</p>
2468
2469<pre class="code">
2470 $x = $image-&gt;Read(...);
2471 warn "$x" if "$x"; # print the error message
2472 $x =~ /(\d+)/;
2473 print $1; # print the error number
2474 print 0+$x; # print the number of images read
2475</pre>
2476
2477<p>Methods which operate on an image (e.g. Resize(), Crop()):</p>
2478
2479<pre class="code">
2480 $x = $image-&gt;Crop(...);
2481 warn "$x" if "$x"; # print the error message
2482 $x =~ /(\d+)/;
2483 print $1; # print the error number
2484</pre>
2485
cristy63fed272010-03-07 19:08:45 +00002486<p>Methods which return images (EvaluateSequence(), Montage(), Clone()) should be checked for errors this way:</p>
cristy3ed852e2009-09-05 21:47:34 +00002487
2488<pre class="code">
2489 $x = $image-&gt;Montage(...);
2490 warn "$x" if !ref($x); # print the error message
2491 $x =~ /(\d+)/;
2492 print $1; # print the error number
2493</pre>
2494
2495<p>Here is an example error message:</p>
2496
2497<pre class="code">
2498 Error 400: Memory allocation failed
2499</pre>
2500
2501<p>Review the complete list of <a href="../www/exception.html">error and warning codes</a>.</p>
2502
2503<p>The following illustrates how you can use a numeric status code:</p>
2504
2505<pre class="code">
2506 $x = $image-&gt;Read('rose.png');
2507 $x =~ /(\d+)/;
2508 die "unable to continue" if ($1 == ResourceLimitError);
2509</pre>
2510
2511</div>
2512
2513<h2><a name="constants"></a>Constants</h2>
2514<div class="doc-section">
2515
2516<p>PerlMagick includes these constants:</p>
2517
2518<pre class="text">
2519 BlobError
2520 BlobWarning
2521 CacheError
2522 CacheWarning
2523 CoderError
2524 CoderWarning
2525 ConfigureError
2526 ConfigureWarning
2527 CorruptImageError
2528 CorruptImageWarning
2529 DelegateError
2530 DelegateWarning
2531 DrawError
2532 DrawWarning
2533 ErrorException
2534 FatalErrorException
2535 FileOpenError
2536 FileOpenWarning
2537 ImageError
2538 ImageWarning
2539 MissingDelegateError
2540 MissingDelegateWarning
2541 ModuleError
2542 ModuleWarning
2543 Opaque
2544 OptionError
2545 OptionWarning
2546 QuantumDepth
2547 QuantumRange
2548 RegistryError
2549 RegistryWarning
2550 ResourceLimitError
2551 ResourceLimitWarning
2552 StreamError
2553 StreamWarning
2554 Success
2555 Transparent
2556 TypeError
2557 TypeWarning
2558 WarningException
2559 XServerError
2560 XServerWarning
2561</pre>
2562
2563<p>You can access them like this:</p>
2564
2565<pre class="code">
2566 Image::Magick-&gt;QuantumDepth
2567</pre>
2568
2569</div>
cristy3eaa0ef2010-03-06 20:35:26 +00002570
2571</div>
2572
2573<div id="linkbar">
cristyce69bb02010-07-27 19:49:46 +00002574 <span id="linkbar-west">&nbsp;</span>
cristy3eaa0ef2010-03-06 20:35:26 +00002575 <span id="linkbar-center">
2576 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
cristya8902942010-07-30 00:49:52 +00002577 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
cristy3eaa0ef2010-03-06 20:35:26 +00002578 </span>
2579 <span id="linkbar-east">&nbsp;</span>
2580 </div>
2581 <div class="footer">
cristy7e41fe82010-12-04 23:12:08 +00002582 <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>
cristy3eaa0ef2010-03-06 20:35:26 +00002583 <span id="footer-east"> <a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
2584 </div>
2585 <div style="clear: both; margin: 0; width: 100%; "></div>
cristya8902942010-07-30 00:49:52 +00002586 <script type="text/javascript">
2587 var _gaq = _gaq || [];
2588 _gaq.push(['_setAccount', 'UA-17690367-1']);
2589 _gaq.push(['_trackPageview']);
2590
2591 (function() {
2592 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
2593 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
2594 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
2595 })();
2596 </script>
cristy3eaa0ef2010-03-06 20:35:26 +00002597</body>
2598</html>