blob: c4d8a6780a2c5f732ffbd0e53de6781abe93c229 [file] [log] [blame]
cristydcca3fa2010-12-29 21:50:07 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml: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"/>
cristydcca3fa2010-12-29 21:50:07 +000012 <meta name="Description" content="ImageMagick is a software suite to create, edit, compose, or convert 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"/>
cristydcca3fa2010-12-29 21:50:07 +000024 <link rel="icon" href="../images/wand.png"/>
cristy3c98a4f2010-08-13 20:09:41 +000025 <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>
cristydcca3fa2010-12-29 21:50:07 +000030 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
cristy361f4662010-12-31 23:02:52 +000031 <script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>
32 <link rel="stylesheet" type="text/css" href="../fancybox/jquery.fancybox-1.3.4.css" media="screen" />
33 <script type="text/javascript">
34 $(document).ready(function() {
35 $("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({
36 'transitionIn' : 'elastic',
37 'transitionOut' : 'elastic',
38 'overlayShow' : false,
39 'opacity' : true
40 });
41 });
42 </script>
cristy3eaa0ef2010-03-06 20:35:26 +000043</head>
44
45<body id="www-imagemagick-org">
46<div class="titlebar">
47<a href="../index.html">
48 <img src="../images/script.png" alt="[ImageMagick]"
49 style="width: 350px; height: 60px; margin: 28px auto; float: left;" /></a>
50<a href="http://www.networkredux.com">
51 <img src="../images/networkredux.png" alt="[sponsor]"
52 style="margin: 45px auto; border: 0px; float: left;" /></a>
53<a href="http://www.imagemagick.org/discourse-server/">
54 <img src="../images/logo.jpg" alt=""
55 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
56<a href="../index.html">
57 <img src="../images/sprite.jpg" alt=""
58 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
59</div>
60
cristyce69bb02010-07-27 19:49:46 +000061<div class="westbar">
cristy3eaa0ef2010-03-06 20:35:26 +000062
cristy3ed852e2009-09-05 21:47:34 +000063<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000064 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
cristy3ed852e2009-09-05 21:47:34 +000065</div>
cristy3eaa0ef2010-03-06 20:35:26 +000066<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +000067<div class="menu">
cristybb503372010-05-27 20:51:26 +000068 <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
69</div>
70<div class="sub">
71 <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
72</div>
73<div class="sub">
74 <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
75</div>
76<div class="sub">
77 <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
78</div>
79<div class="sep"></div>
80<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000081 <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
cristy3ed852e2009-09-05 21:47:34 +000082</div>
83<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000084 <a title="Command-line Tools: Processing" href="../www/command-line-processing.html">Processing</a>
cristy3ed852e2009-09-05 21:47:34 +000085</div>
86<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000087 <a title="Command-line Tools: Options" href="../www/command-line-options.html">Options</a>
cristy3ed852e2009-09-05 21:47:34 +000088</div>
89<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000090 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
cristy3ed852e2009-09-05 21:47:34 +000091</div>
92<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000093 <a title="Program Interfaces" href="../www/api.html">Program Interfaces</a>
cristy3ed852e2009-09-05 21:47:34 +000094</div>
95<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000096 <a title="Program Interface: MagickWand" href="../www/magick-wand.html">MagickWand</a>
cristy3ed852e2009-09-05 21:47:34 +000097</div>
98<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000099 <a title="Program Interface: MagickCore" href="../www/magick-core.html">MagickCore</a>
cristy3ed852e2009-09-05 21:47:34 +0000100</div>
101<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000102 <a title="Program Interface: PerlMagick" href="../www/perl-magick.html">PerlMagick</a>
cristy3ed852e2009-09-05 21:47:34 +0000103</div>
104<div class="sub">
cristydcca3fa2010-12-29 21:50:07 +0000105 <a title="Program Interface: Magick++" href="../www/magick++.html">Magick++</a>
cristy3ed852e2009-09-05 21:47:34 +0000106</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000107<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000108<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000109 <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
cristy3ed852e2009-09-05 21:47:34 +0000110</div>
111<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000112 <a title="Install from Source: Unix" href="../www/install-source.html#unix">Unix</a>
cristy3ed852e2009-09-05 21:47:34 +0000113</div>
114<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000115 <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
cristy3ed852e2009-09-05 21:47:34 +0000116 </div>
117<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000118 <a title="Resources" href="../www/resources.html">Resources</a>
cristy3ed852e2009-09-05 21:47:34 +0000119</div>
cristybb503372010-05-27 20:51:26 +0000120<div class="menu">
121 <a title="Architecture" href="../www/architecture.html">Architecture</a>
122</div>
cristy3ed852e2009-09-05 21:47:34 +0000123<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000124 <a title="Download" href="../www/download.html">Download</a>
cristy3ed852e2009-09-05 21:47:34 +0000125</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000126<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000127<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000128 <a title="Search" href="http://www.imagemagick.org/script/search.php">Search</a>
cristy3ed852e2009-09-05 21:47:34 +0000129</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000130<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000131<div class="menu">
cristyffb69ed2010-12-25 00:06:48 +0000132 <a title="Site Map" href="../www/sitemap.html">Site Map</a>
cristy3ed852e2009-09-05 21:47:34 +0000133</div>
134<div class="sub">
cristyffb69ed2010-12-25 00:06:48 +0000135 <a title="Site Map: Links" href="../www/links.html">Links</a>
cristy3ed852e2009-09-05 21:47:34 +0000136</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000137<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000138<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000139 <a title="Sponsors" href="../www/sponsors.html">Sponsors:</a>
cristy3ed852e2009-09-05 21:47:34 +0000140
141<div class="sponsbox">
cristyec6b4752011-01-08 03:16:23 +0000142<div class="sponsor">
143 <a title="Sponsor: Web Hosting" href="http://www.bodhost.com/hosting.html">Web Hosting</a><!-- 201104010090 -->
cristy5c4585b2010-11-11 00:13:57 +0000144</div>
145<div class="sponsor">
cristy7d52cd62010-10-01 17:26:59 +0000146 <a title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 201110010720 -->
147</div>
148<div class="sponsor">
cristyc5baf4f2010-08-31 15:05:33 +0000149 <a title="Sponsor: Image Converter" href="http://www.batchphoto.com">Image Converter</a><!-- 201103010900 Bits Coffee-->
150</div>
151<div class="sponsor">
cristy851dbce2010-08-06 21:40:00 +0000152 <a title="Sponsor: Flyer drucken" href="http://www.online-druck.biz">Flyer drucken</a><!-- 201109010900 Floeter-->
153</div>
cristyec6b4752011-01-08 03:16:23 +0000154<div class="sponsor">
155 <a title="Sponsor: alaTest.com" href="http://alatest.com">alaTest.com</a><!-- 20110801000300 -->
156</div>
cristy3ed852e2009-09-05 21:47:34 +0000157</div>
158</div>
cristyce69bb02010-07-27 19:49:46 +0000159</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000160
cristyce69bb02010-07-27 19:49:46 +0000161<div class="eastbar">
162 <script type="text/javascript">
163 <!--
164 google_ad_client = "pub-3129977114552745";
cristyce69bb02010-07-27 19:49:46 +0000165 google_ad_slot = "0574824969";
166 google_ad_width = 160;
167 google_ad_height = 600;
168 //-->
169 </script>
170 <script type="text/javascript"
171 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
172 </script>
cristy3eaa0ef2010-03-06 20:35:26 +0000173</div>
174
175<div class="main">
176
177
cristyffb69ed2010-12-25 00:06:48 +0000178<h1>ImageMagick PerlMagick API</h1>
cristy3ed852e2009-09-05 21:47:34 +0000179<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>
180
181<div class="doc-section">
cristydcca3fa2010-12-29 21:50:07 +0000182<a id="introduction"></a>
cristyf3bb4782009-09-08 13:10:04 +0000183<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 +0000184
185<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>
186
187<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>
188</div>
189
cristydcca3fa2010-12-29 21:50:07 +0000190<h2><a id="installation"></a>Installation</h2>
cristy3ed852e2009-09-05 21:47:34 +0000191<div class="doc-section">
192
193<p><b>UNIX</b></p>
194
195<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>
196
197<p>ImageMagick must already be installed on your system. Next, get
198the <a href="../www/download.html">PerlMagick</a> distribution corresponding to the installed ImageMagick distribution
cristyec6b4752011-01-08 03:16:23 +0000199(e.g., PerlMagick 6.67 for
200ImageMagick 6.6.7) and unpack it as shown below:</p>
cristy3ed852e2009-09-05 21:47:34 +0000201
cristyec6b4752011-01-08 03:16:23 +0000202<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>tar xvfz PerlMagick-6.67.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 +0000203<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 +0000204
205<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>
206<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>
207
208<p><b>Windows XP / Windows 2000</b></p>
209
210<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>
211
212<p>Next, type</p>
213
214<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>
215<p>See the <a href="http://www.dylanbeattie.net/magick/">PerlMagick Windows HowTo</a> page for further installation instructions.</p>
216
217<p><b>Running the Regression Tests</b></p>
218
219<p>To verify a correct installation, type</p>
220
221<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>make test</span></p>
222<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>
223
224<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>
225<p>You are now ready to utilize the PerlMagick methods from within your Perl scripts.</p>
226
227</div>
228
cristydcca3fa2010-12-29 21:50:07 +0000229<h2><a id="overview"></a>Overview</h2>
cristy3ed852e2009-09-05 21:47:34 +0000230<div class="doc-section">
231
232<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>
233
234<pre class="code">
235 use Image::Magick;
236
237 $image=Image::Magick-&gt;new;
238</pre>
239
240<p>The new() method takes the same parameters as <a href="#set-attribute">SetAttribute</a> . For example,</p>
241
242<pre class="code">
243 $image=Image::Magick-&gt;new(size=&gt;'384x256');
244</pre>
245
246<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>
247
cristyc1c61662009-09-30 14:04:37 +0000248<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 +0000249
250<pre class="code">
251 undef $image;
252</pre>
253
254<p>To delete all the images but retain the <kbd>Image::Magick</kbd> object use</p>
255
256<pre class="code">
257 @$image = ();
258</pre>
259
260<p>and finally, to delete a single image from a multi-image sequence, use</p>
261
262<pre class="code">
263 undef $image-&gt;[$x];
264</pre>
265
266<p>The next section illustrates how to use various PerlMagick methods to manipulate an image sequence.</p>
267
268<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>
269
270<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>$ENV{PATH}='/../bin:/usr/bin:/usr/local/bin';</span></p>
271<div style="margin: auto;">
cristydcca3fa2010-12-29 21:50:07 +0000272<h2><a id="example"></a>Example Script</h2>
cristy3ed852e2009-09-05 21:47:34 +0000273</div>
274
275<p>Here is an example script to get you started:</p>
276
277<pre class="code">
278 #!/usr/local/bin/perl
279 use Image::Magick;<br />
280 my($image, $x);<br />
281 $image = Image::Magick-&gt;new;
282 $x = $image-&gt;Read('girl.png', 'logo.png', 'rose.png');
283 warn "$x" if "$x";<br />
284 $x = $image-&gt;Crop(geometry=&gt;'100x100+100+100');
285 warn "$x" if "$x";<br />
286 $x = $image-&gt;Write('x.png');
287 warn "$x" if "$x";
288</pre>
289
290<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>
291
292<pre class="code">
293 #!/usr/local/bin/perl
294 use Image::Magick;<br />
295 my($image, $p, $q);<br />
296 $image = new Image::Magick;
297 $image-&gt;Read('x1.png');
298 $image-&gt;Read('j*.jpg');
299 $image-&gt;Read('k.miff[1, 5, 3]');
300 $image-&gt;Contrast();
301 for ($x = 0; $image-&gt;[$x]; $x++)
302 {
303 $image-&gt;[$x]-&gt;Frame('100x200') if $image-&gt;[$x]-&gt;Get('magick') eq 'GIF';
304 undef $image-&gt;[$x] if $image-&gt;[$x]-&gt;Get('columns') &lt; 100;
305 }
306 $p = $image-&gt;[1];
307 $p-&gt;Draw(stroke=&gt;'red', primitive=&gt;'rectangle', points=&gt;20,20 100,100');
308 $q = $p-&gt;Montage();
309 undef $image;
310 $q-&gt;Write('x.miff');
311</pre>
312
313<p>Suppose you want to start out with a 100 by 100 pixel white canvas with a red pixel in the center. Try</p>
314
315<pre class="code">
316 $image = Image::Magick-&gt;new;
317 $image-&gt;Set(size=&gt;'100x100');
318 $image-&gt;ReadImage('xc:white');
319 $image-&gt;Set('pixel[49,49]'=&gt;'red');
320</pre>
321
322<p>Here we reduce the intensity of the red component at (1,1) by half:</p>
323
324<pre class="code">
325 @pixels = $image-&gt;GetPixel(x=&gt;1,y=&gt;1);
326 $pixels[0]*=0.5;
327 $image-&gt;SetPixel(x=&gt;1,y=&gt;1,color=&gt;\@pixels);
328</pre>
329
330<p>Or suppose you want to convert your color image to grayscale:</p>
331
332<pre class="code">
333 $image-&gt;Quantize(colorspace=&gt;'gray');
334</pre>
335
336<p>Let's annotate an image with a Taipai TrueType font:</p>
337
338<pre class="code">
339 $text = 'Works like magick!';
340 $image-&gt;Annotate(font=&gt;'kai.ttf', pointsize=&gt;40, fill=&gt;'green', text=&gt;$text);
341</pre>
342
343<p>Perhaps you want to extract all the pixel intensities from an image and write them to STDOUT:</p>
344
345<pre class="code">
346 @pixels = $image-&gt;GetPixels(map=&gt;'I', height=&gt;$height, width=&gt;$width, normalize=&gt;true);
347 binmode STDOUT;
348 print pack('B*',join('',@pixels));
349</pre>
350
351<p>Other clever things you can do with a PerlMagick objects include</p>
352
353<pre class="code">
354 $i = $#$p"+1"; # return the number of images associated with object p
355 push(@$q, @$p); # push the images from object p onto object q
356 @$p = (); # delete the images but not the object p
357 $p-&gt;Convolve([1, 2, 1, 2, 4, 2, 1, 2, 1]); # 3x3 Gaussian kernel
358</pre>
359
360<div style="margin: auto;">
cristydcca3fa2010-12-29 21:50:07 +0000361 <h2><a id="read"></a>Read or Write an Image</h2>
cristy3ed852e2009-09-05 21:47:34 +0000362</div>
363
364<p>Use the methods listed below to either read, write, or display an image or image sequence:</p>
365
366<table class="doc">
367<caption>Read or Write Methods</caption>
368<colgroup>
369 <col width="20%"></col>
370 <col width="20%"></col>
371 <col width="20%"></col>
372 <col width="40%"></col>
373</colgroup>
374<tbody>
375
376 <tr>
377 <th>Method</th>
378 <th>Parameters</th>
379 <th>Return Value</th>
380 <th>Description</th>
381 </tr>
382
383 <tr>
384 <td valign="top">Read</td>
385 <td valign="top">one or more filenames</td>
386 <td valign="top">the number of images read</td>
387 <td valign="top">read an image or image sequence</td>
388 </tr>
389
390 <tr>
391 <td valign="top">Write</td>
392 <td valign="top">filename</td>
393 <td valign="top">the number of images written</td>
394 <td valign="top">write an image or image sequence</td>
395 </tr>
396
397 <tr>
398 <td valign="top">Display</td>
399 <td valign="top">server name</td>
400 <td valign="top">the number of images displayed</td>
401 <td valign="top">display the image or image sequence to an X server</td>
402 </tr>
403
404 <tr>
405 <td valign="top">Animate</td>
406 <td valign="top">server name</td>
407 <td valign="top">the number of images animated</td>
408 <td valign="top">animate image sequence to an X server</td>
409 </tr>
410</tbody>
411</table>
412
413<p>For convenience, methods Write(), Display(), and Animate() can take any parameter that <a href="#set-attribute">SetAttribute</a> knows about. For example,</p>
414
415<pre class="code">
416 $image-&gt;Write(filename=&gt;'image.png', compression=&gt;'None');
417</pre>
418
419<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>
420
421<pre class="code">
422 binmode STDOUT;
423 $image-&gt;Write('png:-');
424</pre>
425
426<p>To read an image in the GIF format from a PERL filehandle, use:</p>
427
428<pre class="code">
429 $image = Image::Magick-&gt;new;
430 open(IMAGE, 'image.gif');
431 $image-&gt;Read(file=&gt;\*IMAGE);
432 close(IMAGE);
433</pre>
434
435<p>To write an image in the PNG format to a PERL filehandle, use:</p>
436
437<pre class="code">
438 $filename = "image.png";
439 open(IMAGE, ">$filename");
440 $image-&gt;Write(file=&gt;\*IMAGE, filename=&gt;$filename);
441 close(IMAGE);
442</pre>
443
cristycb03ed62009-12-11 21:30:51 +0000444<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>
445
cristy3ed852e2009-09-05 21:47:34 +0000446<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>
447
448<pre class="text">
449 image%03d.miff
450</pre>
451
452<p>converts files image000.miff, image001.miff, etc.</p>
453
454<p>You can optionally add <i>Image</i> to any method name. For example, ReadImage() is an alias for method Read().</p>
455
456</div>
457
cristydcca3fa2010-12-29 21:50:07 +0000458<h2><a id="manipulate"></a>Manipulate an Image</h2>
cristy3ed852e2009-09-05 21:47:34 +0000459<div class="doc-section">
460
461<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>
462
463<pre class="code">
464 $image-&gt;Crop(geometry=&gt;'100x100+10+20');
465 $image-&gt;[$x]-&gt;Frame("100x200");
466</pre>
467
468<p>And here is a list of other image manipulation methods you can call:</p>
469
470<table class="doc">
471<caption>Image Manipulation Methods</caption>
472<tbody>
473 <tr>
474 <th>Method</th>
475 <th style="width: 40%">Parameters</th>
476 <th style="width: 40%">Description</th>
477 </tr>
478
479 <tr>
480 <td valign="top">AdaptiveBlur</td>
481 <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>
482 <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>
483 </tr>
484
485 <tr>
486 <td valign="top">AdaptiveResize</td>
487 <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>
488 <td valign="top">adaptively resize image using data dependant triangulation. Specify <kbd>blur</kbd> &gt; 1 for blurry or &lt; 1 for sharp</td>
489 </tr>
490
491 <tr>
492 <td valign="top">AdaptiveSharpen</td>
493 <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>
494 <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>
495 </tr>
496
497 <tr>
498 <td valign="top">AdaptiveThreshold</td>
499 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i>, offset=&gt;<i>integer</i></td>
500 <td valign="top">local adaptive thresholding.</td>
501 </tr>
502
503 <tr>
504 <td valign="top">AddNoise</td>
505 <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>
506 <td valign="top">add noise to an image</td>
507 </tr>
508
509 <tr>
510 <td valign="top">AffineTransform</td>
511 <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>
512 <td valign="top">affine transform image</td>
513 </tr>
514
515 <tr>
516 <td valign="top">Affinity</td>
517 <td valign="top">image=&gt;<i>image-handle</i>, method=&gt;{None, FloydSteinberg, Riemersma}</td>
518 <td valign="top">choose a particular set of colors from this image</td>
519 </tr>
520
521 <tr>
522 <td valign="top">Annotate</td>
cristybebec402010-04-23 19:19:08 +0000523 <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 +0000524 <td valign="top">annotate an image with text. See <a href="#misc">QueryFontMetrics</a> to get font metrics without rendering any text.</td>
525 </tr>
526
527 <tr>
528 <td valign="top">AutoGamma</td>
529 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
530 <td valign="top">automagically adjust gamma level of image</td>
531 </tr>
532
533 <tr>
534 <td valign="top">AutoLevel</td>
535 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
536 <td valign="top">automagically adjust color levels of image</td>
537 </tr>
538
539 <tr>
540 <td valign="top">AutoOrient</td>
541 <td valign="top"><br /></td>
542 <td valign="top">automagically orient the image</td>
543 </tr>
544
545 <tr>
546 <td valign="top">BlackThreshold</td>
cristyec407392009-11-28 22:42:05 +0000547 <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 +0000548 <td valign="top">force all pixels below the threshold intensity into black</td>
549 </tr>
550
551 <tr>
552 <td valign="top">BlueShift</td>
553 <td valign="top">factor=&gt;<i>double</i>,</td>
554 <td valign="top">simulate a scene at nighttime in the moonlight. Start with a factor of 1.5.</td>
555 </tr>
556
557 <tr>
558 <td valign="top">Blur</td>
559 <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>
560 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td>
561 </tr>
562
563 <tr>
564 <td valign="top">Border</td>
565 <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>
566 <td valign="top">surround the image with a border of color</td>
567 </tr>
568
569 <tr>
570 <td valign="top">Charcoal</td>
571 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i></td>
572 <td valign="top">simulate a charcoal drawing</td>
573 </tr>
574
575 <tr>
576 <td valign="top">Chop</td>
577 <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>
578 <td valign="top">chop an image</td>
579 </tr>
580
581 <tr>
cristyb4c03bb2009-09-27 13:55:46 +0000582 <td valign="top">Clamp</td>
583 <td valign="top"><br /></td>
584 <td valign="top">restrict color values from 0 to the quantum depth.</td>
585 </tr>
586
587 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000588 <td valign="top">Clip</td>
589 <td valign="top">id=&gt;<i>name</i>, inside=&gt;<i>{true, false}</i>,</td>
590 <td valign="top">apply along a named path from the 8BIM profile.</td>
591 </tr>
592
593 <tr>
594 <td valign="top">ClipMask</td>
595 <td valign="top">mask=&gt;<i>image-handle</i></td>
596 <td valign="top">clip image as defined by the image mask</td>
597 </tr>
598
599 <tr>
600 <td valign="top">Clut</td>
601 <td valign="top">image=&gt;<i>image-handle</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
602 <td valign="top">apply a color lookup table to an image sequence</td>
603 </tr>
604
605 <tr>
606 <td valign="top">Coalesce</td>
607 <td valign="top"><br /></td>
608 <td valign="top">merge a sequence of images</td>
609 </tr>
610
611 <tr>
cristy83a272e2010-05-07 20:40:35 +0000612 <td valign="top">Color</td>
613 <td valign="top">color=&gt;<i><a href="../www/color.html">color name</a></i></td>
614 <td valign="top">set the entire image to this color.</td>
615 </tr>
616
617 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000618 <td valign="top">ColorDecisionList</td>
619 <td valign="top">filename=&gt;<i>string</i>,</td>
620 <td valign="top">color correct with a color decision list.</td>
621 </tr>
622
623 <tr>
624 <td valign="top">Colorize</td>
625 <td valign="top">fill=&gt;<i><a href="../www/color.html">color name</a></i>, opacity=&gt;<i>string</i></td>
626 <td valign="top">colorize the image with the fill color</td>
627 </tr>
628
629 <tr>
cristy2c839602010-04-03 02:32:08 +0000630 <td valign="top">ColorMatrix</td>
631 <td valign="top">matrix=&gt;<i>array of float values</i></td>
632 <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>
633 </tr>
634
635 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000636 <td valign="top">Comment</td>
637 <td valign="top">string</td>
638 <td valign="top">add a comment to your image</td>
639 </tr>
640
641 <tr>
642 <td valign="top">CompareLayers</td>
643 <td valign="top">method=&gt;{any, clear, overlay}</td>
644 <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>
645 </tr>
646
647 <tr>
648 <td valign="top">Composite</td>
649 <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>
650 <td valign="top">composite one image onto another. Use the rotate parameter in concert with the tile parameter.</td>
651 </tr>
652
653 <tr>
654 <td valign="top">Contrast</td>
655 <td valign="top">sharpen=&gt;{True, False}</td>
656 <td valign="top">enhance or reduce the image contrast</td>
657 </tr>
658
659 <tr>
660 <td valign="top">ContrastStretch</td>
661 <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>
662 <td valign="top">improve the contrast in an image by `stretching' the range of intensity values</td>
663 </tr>
664
665 <tr>
666 <td valign="top">Convolve</td>
cristy16ff93c2010-01-13 23:18:07 +0000667 <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 +0000668 <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>
669 </tr>
670
671 <tr>
672 <td valign="top">Crop</td>
cristya13871a2009-12-06 19:01:22 +0000673 <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 +0000674 <td valign="top">crop an image</td>
675 </tr>
676
677 <tr>
678 <td valign="top">CycleColormap</td>
679 <td valign="top">amount=&gt;<i>integer</i></td>
680 <td valign="top">displace image colormap by amount</td>
681 </tr>
682
683 <tr>
684 <td valign="top">Decipher</td>
685 <td valign="top">passphrase=&gt;<i>string</i></td>
686 <td valign="top">convert cipher pixels to plain pixels</td>
687 </tr>
688
689 <tr>
690 <td valign="top">Deconstruct</td>
691 <td valign="top"><br /></td>
692 <td valign="top">break down an image sequence into constituent parts</td>
693 </tr>
694
695 <tr>
696 <td valign="top">Deskew</td>
697 <td valign="top">geometry=&gt;<i>string</i>,threshold=&gt;<i>double</i></td>
698 <td valign="top">straighten the image</td>
699 </tr>
700
701 <tr>
702 <td valign="top">Despeckle</td>
703 <td valign="top">&nbsp;</td>
704 <td valign="top">reduce the speckles within an image</td>
705 </tr>
706
707 <tr>
708 <td valign="top">Difference</td>
709 <td valign="top">image=&gt;<i>image-handle</i></td>
710 <td valign="top">compute the difference metrics between two images </td>
711 </tr>
712
713 <tr>
714 <td valign="top">Distort</td>
715 <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>
716 <td valign="top">distort image</td>
717 </tr>
718
719 <tr>
720 <td valign="top">Draw</td>
cristybebec402010-04-23 19:19:08 +0000721 <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 +0000722 <td valign="top">annotate an image with one or more graphic primitives.</td>
723 </tr>
724
725 <tr>
726 <td valign="top">Encipher</td>
727 <td valign="top">passphrase=&gt;<i>string</i></td>
728 <td valign="top">convert plain pixels to cipher pixels</td>
729 </tr>
730
731 <tr>
732 <td valign="top">Edge</td>
733 <td valign="top">radius=&gt;<i>double</i></td>
734 <td valign="top">enhance edges within the image with a convolution filter of the given radius.</td>
735 </tr>
736
737 <tr>
738 <td valign="top">Emboss</td>
739 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i></td>
740 <td valign="top">emboss the image with a convolution filter of the given radius and standard deviation (sigma).</td>
741 </tr>
742
743 <tr>
744 <td valign="top">Enhance</td>
745 <td valign="top"><br /></td>
746 <td valign="top">apply a digital filter to enhance a noisy image</td>
747 </tr>
748
749 <tr>
750 <td valign="top">Equalize</td>
751 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}<br /></td>
752 <td valign="top">perform histogram equalization to the image</td>
753 </tr>
754
755 <tr>
756 <td valign="top">Extent</td>
757 <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>
758 <td valign="top">set the image size</td>
759 </tr>
760
761 <tr>
762 <td valign="top">Evaluate</td>
763 <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>
764 <td valign="top">apply an arithmetic, relational, or logical expression to the image</td>
765 </tr>
766
767 <tr>
cristy16ff93c2010-01-13 23:18:07 +0000768 <td valign="top">Filter</td>
769 <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>
770 <td valign="top">apply a convolution kernel to the image.</td>
771 </tr>
772
773 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000774 <td valign="top">Flip</td>
775 <td valign="top"><br /></td>
776 <td valign="top">reflect the image scanlines in the vertical direction</td>
777 </tr>
778
779 <tr>
780 <td valign="top">Flop</td>
781 <td valign="top"><br /></td>
782 <td valign="top">reflect the image scanlines in the horizontal direction</td>
783 </tr>
784
785 <tr>
786 <td valign="top">FloodfillPaint</td>
787 <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>
788 <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>
789 </tr>
790
791 <tr>
792 <td valign="top">ForwardFourierTransform</td>
793 <td valign="top">magnitude=&gt;{True, False}</td>
794 <td valign="top">implements the forward discrete Fourier transform (DFT)</td>
795 </tr>
796
797 <tr>
798 <td valign="top">Frame</td>
799 <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>
800 <td valign="top">surround the image with an ornamental border</td>
801 </tr>
802
803 <tr>
804 <td valign="top">Function</td>
805 <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>
806 <td valign="top">apply a function to the image</td>
807 </tr>
808
809 <tr>
810 <td valign="top">Gamma</td>
811 <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>
812 <td valign="top">gamma correct the image</td>
813 </tr>
814
815 <tr>
816 <td valign="top">GaussianBlur</td>
817 <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>
818 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td>
819 </tr>
820
821 <tr>
822 <td valign="top">GetPixel</td>
823 <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>
824 <td valign="top">get a single pixel. By default normalized pixel values are returned.</td>
825 </tr>
826
827 <tr>
828 <td valign="top">GetPixels</td>
829 <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>
830 <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>
831 </tr>
832
833 <tr>
834 <td valign="top">HaldClut</td>
835 <td valign="top">image=&gt;<i>image-handle</i>, channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
836 <td valign="top">apply a Hald color lookup table to an image sequence</td>
837 </tr>
838
839 <tr>
840 <td valign="top">Identify</td>
cristy045bd902010-01-30 18:56:24 +0000841 <td valign="top">file=&gt;<i>file</i>, features=&gt;<i>distance</i>, unique=&gt;{True, False}</td>
cristy3ed852e2009-09-05 21:47:34 +0000842 <td valign="top">identify the attributes of an image</td>
843 </tr>
844
845 <tr>
846 <td valign="top">Implode</td>
847 <td valign="top">amount=&gt;<i>double</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
848 <td valign="top">implode image pixels about the center</td>
849 </tr>
850
851 <tr>
852 <td valign="top">InverseDiscreteFourierTransform</td>
853 <td valign="top">magnitude=&gt;{True, False}</td>
854 <td valign="top">implements the inverse discrete Fourier transform (DFT)</td>
855 </tr>
856
857 <tr>
858 <td valign="top">Label</td>
859 <td valign="top">string</td>
860 <td valign="top">assign a label to an image</td>
861 </tr>
862
863 <tr>
864 <td valign="top">Layers</td>
865 <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>
866 <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>
867 </tr>
868
869 <tr>
870 <td valign="top">Level</td>
871 <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>
872 <td valign="top">adjust the level of image contrast</td>
873 </tr>
874
875 <tr>
cristye7f8fdd2009-09-20 14:43:12 +0000876 <td valign="top">LevelColors</td>
877 <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>
878 <td valign="top">level image with the given colors</td>
879 </tr>
880
881 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000882 <td valign="top">LinearStretch</td>
883 <td valign="top">levels=&gt;<i>string</i>, 'black-point'=&gt;<i>double</i>, 'white-point'=&gt;<i>double</i></td>
884 <td valign="top">linear with saturation stretch</td>
885 </tr>
886
887 <tr>
888 <td valign="top">LiquidResize</td>
889 <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>
890 <td valign="top">rescale image with seam-carving.</td>
891 </tr>
892
893 <tr>
894 <td valign="top">Magnify</td>
895 <td valign="top"><br /></td>
896 <td valign="top">double the size of an image</td>
897 </tr>
898
899 <tr>
900 <td valign="top">Mask</td>
901 <td valign="top">mask=&gt;<i>image-handle</i></td>
902 <td valign="top">composite image pixels as defined by the mask</td>
903 </tr>
904
905 <tr>
906 <td valign="top">MatteFloodfill</td>
907 <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>
908 <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>
909 </tr>
910
911 <tr>
912 <td valign="top">MedianFilter</td>
913 <td valign="top">radius=&gt;<i>double</i></td>
914 <td valign="top">replace each pixel with the median intensity pixel of a neighborhood.</td>
915 </tr>
916
917 <tr>
918 <td valign="top">Minify</td>
919 <td valign="top"><br /></td>
920 <td valign="top">half the size of an image</td>
921 </tr>
922
923 <tr>
924 <td valign="top">Modulate</td>
925 <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>
926 <td valign="top">vary the brightness, saturation, and hue of an image by the specified percentage</td>
927 </tr>
928
929 <tr>
cristy488844c2010-01-22 14:02:05 +0000930 <td valign="top">Morphology</td>
931 <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>
932 <td valign="top">apply a morphology method to the image.</td>
933 </tr>
934
935 <tr>
cristy3ed852e2009-09-05 21:47:34 +0000936 <td valign="top">MotionBlur</td>
937 <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>
938 <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>
939 </tr>
940
941 <tr>
942 <td valign="top">Negate</td>
943 <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 +0000944 <td valign="top">replace each pixel with its complementary color (white becomes black, yellow becomes blue, etc.)</td>
cristy3ed852e2009-09-05 21:47:34 +0000945 </tr>
946
947 <tr>
948 <td valign="top">Normalize</td>
949 <td valign="top">channel=&gt;{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}<br /></td>
950 <td valign="top">transform image to span the full range of color values</td>
951 </tr>
952
953 <tr>
954 <td valign="top">OilPaint</td>
955 <td valign="top">radius=&gt;<i>integer</i></td>
956 <td valign="top">simulate an oil painting</td>
957 </tr>
958
959 <tr>
960 <td valign="top">Opaque</td>
961 <td valign="top">color=&gt;<i><a href="../www/color.html">color name</a></i>,
962fill=&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>
963 <td valign="top">change this color to the fill color within the image</td>
964 </tr>
965
966 <tr>
967 <td valign="top">OrderedDither</td>
968 <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>
969 <td valign="top">order dither image</td>
970 </tr>
971
972 <tr>
973 <td valign="top">Polaroid</td>
974 <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>
975 <td valign="top">simulate a Polaroid picture.</td>
976 </tr>
977
978 <tr>
979 <td valign="top">Posterize</td>
980 <td valign="top">levels=&gt;<i>integer</i>, dither=&gt;{True, False}</td>
981 <td valign="top">reduce the image to a limited number of color level</td>
982 </tr>
983
984 <tr>
985 <td valign="top">Profile</td>
986 <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>
987 <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>
988 </tr>
989
990 <tr>
991 <td valign="top">Quantize</td>
992 <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>
993 <td valign="top">preferred number of colors in the image</td>
994 </tr>
995
996 <tr>
997 <td valign="top">RadialBlur</td>
998 <td valign="top">angle=&gt;<i>double</i></td>
999 <td valign="top">radial blur the image.</td>
1000 </tr>
1001
1002 <tr>
1003 <td valign="top">Raise</td>
1004 <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>
1005 <td valign="top">lighten or darken image edges to create a 3-D effect</td>
1006 </tr>
1007
1008 <tr>
cristy3ed852e2009-09-05 21:47:34 +00001009 <td valign="top">ReduceNoise</td>
1010 <td valign="top">radius=&gt;<i>double</i></td>
1011 <td valign="top">reduce noise in the image with a noise peak elimination filter</td>
1012 </tr>
1013
1014 <tr>
1015 <td valign="top">Remap</td>
cristy8d724052009-11-24 20:52:07 +00001016 <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 +00001017 <td valign="top">replace the colors of an image with the closest color from a reference image.</td>
1018 </tr>
1019
1020 <tr>
1021 <td valign="top">Resample</td>
1022 <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>
1023 <td valign="top">resample image to desired resolution. Specify <kbd>blur</kbd> &gt; 1 for blurry or &lt; 1 for sharp</td>
1024 </tr>
1025
1026 <tr>
1027 <td valign="top">Resize</td>
1028 <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>
1029 <td valign="top">scale image to desired size. Specify <kbd>blur</kbd> &gt; 1 for blurry or &lt; 1 for sharp</td>
1030 </tr>
1031
1032 <tr>
1033 <td valign="top">Roll</td>
1034 <td valign="top">geometry=&gt;<i>geometry</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
1035 <td valign="top">roll an image vertically or horizontally</td>
1036 </tr>
1037
1038 <tr>
1039 <td valign="top">Rotate</td>
1040 <td valign="top">degrees=&gt;<i>double</i>, background=&gt;<i><a href="../www/color.html">color name</a></i></td>
1041 <td valign="top">rotate an image</td>
1042 </tr>
1043
1044 <tr>
1045 <td valign="top">Sample</td>
1046 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1047 <td valign="top">scale image with pixel sampling.</td>
1048 </tr>
1049
1050 <tr>
1051 <td valign="top">Scale</td>
1052 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1053 <td valign="top">scale image to desired size</td>
1054 </tr>
1055
1056 <tr>
1057 <td valign="top">Segment</td>
1058 <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>
1059 <td valign="top">segment an image by analyzing the histograms of the color components and identifying units that are homogeneous</td>
1060 </tr>
1061
1062 <tr>
1063 <td valign="top">SelectiveBlur</td>
1064 <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>
1065 <td valign="top">selectively blur pixels within a contrast threshold.</td>
1066 </tr>
1067 <tr>
1068 <td valign="top">Separate</td>
1069 <td valign="top">channel=&gt;{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
1070 <td valign="top">separate a channel from the image into a grayscale image</td>
1071 </tr>
1072
1073 <tr>
1074 <td valign="top">Shade</td>
1075 <td valign="top">geometry=&gt;<i>geometry</i>, azimuth=&gt;<i>double</i>, elevation=&gt;<i>double</i>, gray=&gt;{true, false}</td>
1076 <td valign="top">shade the image using a distant light source</td>
1077 </tr>
1078
1079 <tr>
1080 <td valign="top">SetPixel</td>
1081 <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>
1082 <td valign="top">set a single pixel. By default normalized pixel values are expected.</td>
1083 </tr>
1084
1085 <tr>
1086 <td valign="top">Shadow</td>
1087 <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>
1088 <td valign="top">simulate an image shadow</td>
1089 </tr>
1090
1091 <tr>
1092 <td valign="top">Sharpen</td>
1093 <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>
1094 <td valign="top">sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma).</td>
1095 </tr>
1096
1097 <tr>
1098 <td valign="top">Shave</td>
1099 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1100 <td valign="top">shave pixels from the image edges</td>
1101 </tr>
1102
1103 <tr>
1104 <td valign="top">Shear</td>
1105 <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>
1106 <td valign="top">shear the image along the X or Y axis by a positive or negative shear angle</td>
1107 </tr>
1108
1109 <tr>
1110 <td valign="top">SigmoidalContrast</td>
1111 <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>
1112 <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>
1113 </tr>
1114
1115 <tr>
1116 <td valign="top">Signature</td>
1117 <td valign="top"><br /></td>
1118 <td valign="top">generate an SHA-256 message digest for the image pixel stream</td>
1119 </tr>
1120
1121 <tr>
1122 <td valign="top">Sketch</td>
1123 <td valign="top">geometry=&gt;<i>geometry</i>, radius=&gt;<i>double</i>, sigma=&gt;<i>double</i>, angle=&gt;<i>double</i></td>
1124 <td valign="top">sketch the image with a Gaussian operator of the given radius and standard deviation (sigma) at the given angle</td>
1125 </tr>
1126
1127 <tr>
1128 <td valign="top">Solarize</td>
1129 <td valign="top">geometry=&gt;<i>string</i>,threshold=&gt;<i>double</i></td>
1130 <td valign="top">negate all pixels above the threshold level</td>
1131 </tr>
1132
1133 <tr>
1134 <td valign="top">SparseColor</td>
1135 <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>
1136 <td valign="top">interpolate the image colors around the supplied points</td>
1137 </tr>
1138
1139 <tr>
1140 <td valign="top">Splice</td>
1141 <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>
1142 <td valign="top">splice an image</td>
1143 </tr>
1144
1145 <tr>
1146 <td valign="top">Spread</td>
1147 <td valign="top">radius=&gt;<i>double</i></td>
1148 <td valign="top">displace image pixels by a random amount</td>
1149 </tr>
1150
1151 <tr>
1152 <td valign="top">Stegano</td>
1153 <td valign="top">image=&gt;<i>image-handle</i>, offset=&gt;<i>integer</i></td>
1154 <td valign="top">hide a digital watermark within the image</td>
1155 </tr>
1156
1157 <tr>
1158 <td valign="top">Stereo</td>
1159 <td valign="top">image=&gt;<i>image-handle</i>, x=&gt;<i>integer</i>, y=&gt;<i>integer</i></td>
1160 <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>
1161 </tr>
1162
1163 <tr>
1164 <td valign="top">Strip</td>
1165 <td valign="top"><br /></td>
1166 <td valign="top">strip an image of all profiles and comments.</td>
1167 </tr>
1168
1169 <tr>
1170 <td valign="top">Swirl</td>
1171 <td valign="top">degrees=&gt;<i>double</i>, interpolate=&gt;{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
1172 <td valign="top">swirl image pixels about the center</td>
1173 </tr>
1174
1175 <tr>
1176 <td valign="top">Texture</td>
1177 <td valign="top">texture=&gt;<i>image-handle</i></td>
1178 <td valign="top">name of texture to tile onto the image background</td>
1179 </tr>
1180
1181 <tr>
1182 <td valign="top">Thumbnail</td>
1183 <td valign="top">geometry=&gt;<i>geometry</i>, width=&gt;<i>integer</i>, height=&gt;<i>integer</i></td>
1184 <td valign="top">changes the size of an image to the given dimensions and removes any associated profiles.</td>
1185 </tr>
1186
1187 <tr>
1188 <td valign="top">Threshold</td>
1189 <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>
1190 <td valign="top">threshold the image</td>
1191 </tr>
1192
1193 <tr>
1194 <td valign="top">Tint</td>
1195 <td valign="top">fill=&gt;<i><a href="../www/color.html">color name</a></i>, opacity=&gt;<i>string</i></td>
1196 <td valign="top">tint the image with the fill color.</td>
1197 </tr>
1198
1199 <tr>
1200 <td valign="top">Transparent</td>
1201 <td valign="top">color=&gt;<i><a href="../www/color.html">color name</a></i>, invert=&gt;{True, False}</td>
1202 <td valign="top">make this color transparent within the image</td>
1203 </tr>
1204
1205 <tr>
1206 <td valign="top">Transpose</td>
1207 <td valign="top"><br /></td>
1208 <td valign="top">flip image in the vertical direction and rotate 90 degrees</td>
1209 </tr>
1210
1211 <tr>
1212 <td valign="top">Transverse</td>
1213 <td valign="top"><br /></td>
1214 <td valign="top">flop image in the horizontal direction and rotate 270 degrees</td>
1215 </tr>
1216
1217 <tr>
1218 <td valign="top">Trim</td>
1219 <td valign="top"><br /></td>
1220 <td valign="top">remove edges that are the background color from the image</td>
1221 </tr>
1222
1223 <tr>
1224 <td valign="top">UnsharpMask</td>
1225 <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>
1226 <td valign="top">sharpen the image with the unsharp mask algorithm.</td>
1227 </tr>
1228
1229 <tr>
1230 <td valign="top">Vignette</td>
1231 <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>
1232 <td valign="top">offset the edges of the image in vignette style</td>
1233 </tr>
1234
1235 <tr>
1236 <td valign="top">Wave</td>
1237 <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>
1238 <td valign="top">alter an image along a sine wave</td>
1239 </tr>
1240
1241 <tr>
1242 <td valign="top">WhiteThreshold</td>
cristyec407392009-11-28 22:42:05 +00001243 <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 +00001244 <td valign="top">force all pixels above the threshold intensity into white</td>
1245 </tr>
1246</tbody>
1247</table>
1248
1249<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>
1250
1251<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>
1252
1253<pre class="code">
1254 $image-&gt;Draw(fill=&gt;'red', primitive=&gt;'rectangle',
1255 points=&gt;'20,20 100,100 40,40 200,200 60,60 300,300');
1256</pre>
1257
1258<p>Is equivalent to</p>
1259
1260<pre class="code">
1261 $image-&gt;Draw(fill=&gt;'red', primitive=&gt;'@draw.txt');
1262</pre>
1263
1264<p>Where <kbd>draw.txt</kbd> is a file on disk that contains this:</p>
1265
1266<pre class="text">
1267 rectangle 20, 20 100, 100
1268 rectangle 40, 40 200, 200
1269 rectangle 60, 60 300, 300
1270</pre>
1271
1272<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>
1273
1274<pre class="text">
1275 %b file size
1276 %c comment
1277 %d directory
1278 %e filename extension
1279 %f filename
1280 %g page geometry
1281 %h height
1282 %i input filename
1283 %k number of unique colors
1284 %l label
1285 %m magick
1286 %n number of scenes
1287 %o output filename
1288 %p page number
1289 %q quantum depth
1290 %r image class and colorspace
1291 %s scene number
1292 %t top of filename
1293 %u unique temporary filename
1294 %w width
1295 %x x resolution
1296 %y y resolution
1297 %z image depth
1298 %C image compression type
1299 %D image dispose method
1300 %H page height
1301 %Q image compression quality
1302 %T image delay
1303 %W page width
1304 %X page x offset
1305 %Y page y offset
1306 %@ bounding box
1307 %# signature
1308 %% a percent sign
1309 \n newline
1310 \r carriage return
1311</pre>
1312
1313<p>For example,</p>
1314
1315<pre class="code">
1316 text=&gt;"%m:%f %wx%h"
1317</pre>
1318
1319<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>
1320
1321<p>You can optionally add <i>Image</i> to any method name. For example, TrimImage() is an alias for method Trim().</p>
1322
1323<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>
1324
1325</div>
1326
cristydcca3fa2010-12-29 21:50:07 +00001327<h2><a id="set-attribute"></a>Set an Image Attribute</h2>
cristy3ed852e2009-09-05 21:47:34 +00001328<div class="doc-section">
1329
1330<p>Use method Set() to set an image attribute. For example,</p>
1331
1332<pre class="code">
1333 $image-&gt;Set(dither=&gt;'True');
1334 $image-&gt;[$x]-&gt;Set(delay=&gt;3);
1335</pre>
1336
1337<p>Where this example uses 'True' and this document says '{True, False}',
1338you can use the case-insensitive strings 'True' and 'False', or you
1339can use the integers 1 and 0.</p>
1340
1341<p>When you call Get() on a Boolean attribute, Image::Magick returns 1 or 0, not a string.</p>
1342
1343<p>And here is a list of all the image attributes you can set:</p>
1344
1345<table class="doc">
1346 <caption>Image Attributes</caption>
1347 <tbody>
1348 <tr>
1349 <th>Attribute</th>
1350 <th style="width: 40%">Values</th>
1351 <th style="width: 40%">Description</th>
1352 </tr>
1353
1354 <tr>
1355 <td valign="top">adjoin</td>
1356 <td valign="top">{True, False}</td>
1357 <td valign="top">join images into a single multi-image file</td>
1358 </tr>
1359
1360 <tr>
1361 <td valign="top">alpha</td>
1362 <td valign="top">{On, Off, Opaque, Transparent, Copy, Extract, Set}</td>
1363 <td valign="top">control of and special operations involving the alpha/matte channel</td>
1364 </tr>
1365
1366 <tr>
1367 <td valign="top">antialias</td>
1368 <td valign="top">{True, False}</td>
1369 <td valign="top">remove pixel aliasing</td>
1370 </tr>
1371
1372 <tr>
1373 <td valign="top">area-limit</td>
1374 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001375 <td valign="top">set pixel area resource limit.</td>
cristy3ed852e2009-09-05 21:47:34 +00001376 </tr>
1377
1378 <tr>
1379 <td valign="top">attenuate</td>
1380 <td valign="top"><i>double</i></td>
1381 <td valign="top">lessen (or intensify) when adding noise to an image.</td>
1382 </tr>
1383
1384 <tr>
1385 <td valign="top">authenticate</td>
1386 <td valign="top"><i>string</i></td>
1387 <td valign="top">decrypt image with this password.</td>
1388 </tr>
1389
1390 <tr>
1391 <td valign="top">background</td>
1392 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1393 <td valign="top">image background color</td>
1394 </tr>
1395
1396 <tr>
1397 <td valign="top">blue-primary</td>
1398 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1399 <td valign="top">chromaticity blue primary point (e.g. 0.15, 0.06)</td>
1400 </tr>
1401
1402 <tr>
1403 <td valign="top">bordercolor</td>
1404 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1405 <td valign="top">set the image border color</td>
1406 </tr>
1407
1408 <tr>
1409 <td valign="top">clip-mask</td>
1410 <td valign="top"><i>image</i></td>
1411 <td valign="top">associate a clip mask with the image.</td>
1412 </tr>
1413
1414 <tr>
1415 <td valign="top">colormap[<i>i</i>]</td>
1416 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1417 <td valign="top">color name (e.g. red) or hex value (e.g. #ccc) at position
1418<i>i</i></td>
1419 </tr>
1420
1421 <tr>
1422 <td valign="top">comment</td>
1423 <td valign="top"><i>string</i></td>
1424 <td valign="top">set the image comment</td>
1425 </tr>
1426
1427 <tr>
1428 <td valign="top">compression</td>
1429 <td valign="top">{None, BZip, Fax, Group4, JPEG, JPEG2000, LosslessJPEG, LZW, RLE, Zip}</td>
1430 <td valign="top">type of image compression</td>
1431 </tr>
1432
1433 <tr>
1434 <td valign="top">debug</td>
1435 <td valign="top">{All, Annotate, Blob, Cache, Coder, Configure, Deprecate, Draw, Exception, Locale, None, Resource, Transform, X11}</td>
1436 <td valign="top">display copious debugging information</td>
1437 </tr>
1438
1439 <tr>
1440 <td valign="top">delay</td>
1441 <td valign="top"><i>integer</i></td>
1442 <td valign="top">this many 1/100ths of a second must expire before displaying the next image in a sequence</td>
1443 </tr>
1444
1445 <tr>
1446 <td valign="top">density</td>
1447 <td valign="top"><i>geometry</i></td>
1448 <td valign="top">vertical and horizontal resolution in pixels of the image</td>
1449 </tr>
1450
1451 <tr>
1452 <td valign="top">depth</td>
1453 <td valign="top"><i>integer</i></td>
1454 <td valign="top">image depth</td>
1455 </tr>
1456
1457 <tr>
cristybebec402010-04-23 19:19:08 +00001458 <td valign="top">direction</td>
1459 <td valign="top"><i>{Undefined, right-to-left, left-to-right</i></td>
1460 <td valign="top">render text right-to-left or left-to-right</td>
1461 </tr>
1462
1463 <tr>
cristy3ed852e2009-09-05 21:47:34 +00001464 <td valign="top">disk-limit</td>
1465 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001466 <td valign="top">set disk resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +00001467 </tr>
1468
1469 <tr>
1470 <td valign="top">dispose</td>
1471 <td valign="top"><i>{Undefined, None, Background, Previous}</i></td>
1472 <td valign="top">layer disposal method</td>
1473 </tr>
1474
1475 <tr>
1476 <td valign="top">dither</td>
1477 <td valign="top">{True, False}</td>
1478 <td valign="top">apply error diffusion to the image</td>
1479 </tr>
1480
1481 <tr>
1482 <td valign="top">display</td>
1483 <td valign="top"><i>string</i></td>
1484 <td valign="top">specifies the X server to contact</td>
1485 </tr>
1486
1487 <tr>
1488 <td valign="top">extract</td>
1489 <td valign="top"><i>geometry</i></td>
1490 <td valign="top">extract area from image</td>
1491 </tr>
1492
1493 <tr>
1494 <td valign="top">file</td>
1495 <td valign="top"><i>filehandle</i></td>
1496 <td valign="top">set the image filehandle</td>
1497 </tr>
1498
1499 <tr>
1500 <td valign="top">filename</td>
1501 <td valign="top"><i>string</i></td>
1502 <td valign="top">set the image filename</td>
1503 </tr>
1504
1505 <tr>
1506 <td valign="top">fill</td>
1507 <td valign="top"><i>color</i></td>
1508 <td valign="top">The fill color paints any areas inside the outline of drawn shape.</td>
1509 </tr>
1510
1511 <tr>
1512 <td valign="top">font</td>
1513 <td valign="top"><i>string</i></td>
1514 <td valign="top">use this font when annotating the image with text</td>
1515 </tr>
1516
1517 <tr>
1518 <td valign="top">fuzz</td>
1519 <td valign="top"><i>integer</i></td>
1520 <td valign="top">colors within this distance are considered equal</td>
1521 </tr>
1522
1523 <tr>
1524 <td valign="top">gamma</td>
1525 <td valign="top"><i>double</i></td>
1526 <td valign="top">gamma level of the image</td>
1527 </tr>
1528
1529 <tr>
1530 <td valign="top">Gravity</td>
1531 <td valign="top">{Forget, NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
1532 <td valign="top">type of image gravity</td>
1533 </tr>
1534
1535 <tr>
1536 <td valign="top">green-primary</td>
1537 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1538 <td valign="top">chromaticity green primary point (e.g. 0.3, 0.6)</td>
1539 </tr>
1540
1541 <tr>
1542 <td valign="top">index[<i>x</i>, <i>y</i>]</td>
1543 <td valign="top"><i>string</i></td>
1544 <td valign="top">colormap index at position (<i>x</i>, <i>y</i>)</td>
1545 </tr>
1546
1547 <tr>
1548 <td valign="top">interlace</td>
1549 <td valign="top">{None, Line, Plane, Partition, JPEG, GIF, PNG}</td>
1550 <td valign="top">the type of interlacing scheme</td>
1551 </tr>
1552
1553 <tr>
1554 <td valign="top">iterations</td>
1555 <td valign="top"><i>integer</i></td>
1556 <td valign="top">add Netscape loop extension to your GIF animation</td>
1557 </tr>
1558
1559 <tr>
1560 <td valign="top">label</td>
1561 <td valign="top"><i>string</i></td>
1562 <td valign="top">set the image label</td>
1563 </tr>
1564
1565 <tr>
1566 <td valign="top">loop</td>
1567 <td valign="top"><i>integer</i></td>
1568 <td valign="top">add Netscape loop extension to your GIF animation</td>
1569 </tr>
1570
1571 <tr>
1572 <td valign="top">magick</td>
1573 <td valign="top"><i>string</i></td>
1574 <td valign="top">set the image format</td>
1575 </tr>
1576
1577 <tr>
1578 <td valign="top">map-limit</td>
1579 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001580 <td valign="top">set map resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +00001581 </tr>
1582
1583 <tr>
1584 <td valign="top">mask</td>
1585 <td valign="top"><i>image</i></td>
1586 <td valign="top">associate a mask with the image.</td>
1587 </tr>
1588
1589 <tr>
1590 <td valign="top">matte</td>
1591 <td valign="top">{True, False}</td>
1592 <td valign="top">enable the image matte channel</td>
1593 </tr>
1594
1595 <tr>
1596 <td valign="top">mattecolor</td>
1597 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1598 <td valign="top">set the image matte color</td>
1599 </tr>
1600
1601 <tr>
1602 <td valign="top">memory-limit</td>
1603 <td valign="top"><i>integer</i></td>
cristyc1c61662009-09-30 14:04:37 +00001604 <td valign="top">set memory resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +00001605 </tr>
1606
1607 <tr>
1608 <td valign="top">monochrome</td>
1609 <td valign="top">{True, False}</td>
1610 <td valign="top">transform the image to black and white</td>
1611 </tr>
1612
1613 <tr>
1614 <td valign="top">option</td>
1615 <td valign="top"><i>string</i></td>
1616 <td valign="top">associate an option with an image format (e.g. option=&gt;'ps:imagemask'</td>
1617 </tr>
1618
1619 <tr>
1620 <td valign="top">orientation</td>
1621 <td valign="top">{top-left, top-right, bottom-right, bottom-left, left-top, right-top, right-bottom, left-bottom}</td>
1622 <td valign="top">image orientation</td>
1623 </tr>
1624
1625 <tr>
1626 <td valign="top">page</td>
1627 <td valign="top">{ Letter, Tabloid, Ledger, Legal, Statement, Executive, A3, A4, A5, B4, B5, Folio, Quarto, 10x14} or <i>geometry</i></td>
1628 <td valign="top">preferred size and location of an image canvas</td>
1629 </tr>
1630
1631 <tr>
1632 <td valign="top">pixel[<i>x</i>, <i>y</i>]</td>
1633 <td valign="top"><i>string</i></td>
1634 <td valign="top">hex value (e.g. #ccc) at position (<i>x</i>, <i>y</i>)</td>
1635 </tr>
1636
1637 <tr>
1638 <td valign="top">pointsize</td>
1639 <td valign="top"><i>integer</i></td>
1640 <td valign="top">pointsize of the Postscript or TrueType font</td>
1641 </tr>
1642
1643 <tr>
1644 <td valign="top">quality</td>
1645 <td valign="top"><i>integer</i></td>
1646 <td valign="top">JPEG/MIFF/PNG compression level</td>
1647 </tr>
1648
1649 <tr>
1650 <td valign="top">red-primary</td>
1651 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1652 <td valign="top">chromaticity red primary point (e.g. 0.64, 0.33)</td>
1653 </tr>
1654
1655 <tr>
1656 <td valign="top">sampling-factor</td>
1657 <td valign="top"><i>geometry</i></td>
1658 <td valign="top">horizontal and vertical sampling factor</td>
1659 </tr>
1660
1661 <tr>
1662 <td valign="top">scene</td>
1663 <td valign="top"><i>integer</i></td>
1664 <td valign="top">image scene number</td>
1665 </tr>
1666
1667 <tr>
1668 <td valign="top">server</td>
1669 <td valign="top"><i>string</i></td>
1670 <td valign="top">specifies the X server to contact</td>
1671 </tr>
1672
1673 <tr>
1674 <td valign="top">size</td>
1675 <td valign="top"><i>string</i></td>
1676 <td valign="top">width and height of a raw image</td>
1677 </tr>
1678
1679 <tr>
1680 <td valign="top">stroke</td>
1681 <td valign="top"><i>color</i></td>
1682 <td valign="top">The stroke color paints along the outline of a shape.</td>
1683 </tr>
1684
1685 <tr>
1686 <td valign="top">texture</td>
1687 <td valign="top"><i>string</i></td>
1688 <td valign="top">name of texture to tile onto the image background</td>
1689 </tr>
1690
1691 <tr>
1692 <td valign="top">tile-offset</td>
1693 <td valign="top"><i>geometry</i></td>
1694 <td valign="top">image tile offset</td>
1695 </tr>
1696
1697 <tr>
1698 <td valign="top">time-limit</td>
1699 <td valign="top"><i>integer</i></td>
1700 <td valign="top">set time resource limit in seconds</td>
1701 </tr>
1702
1703 <tr>
1704 <td valign="top">type</td>
cristyefb2bdb2010-11-20 19:35:22 +00001705 <td valign="top">{Bilevel, Grayscale, GrayscaleMatte, Palette, PaletteMatte, TrueColor, TrueColorMatte, ColorSeparation, ColorSeparationMatte}</td>
cristy3ed852e2009-09-05 21:47:34 +00001706 <td valign="top">image type</td>
1707 </tr>
1708
1709 <tr>
1710 <td valign="top">units</td>
1711 <td valign="top">{ Undefined, PixelsPerInch, PixelsPerCentimeter}</td>
1712 <td valign="top">units of image resolution</td>
1713 </tr>
1714
1715 <tr>
1716 <td valign="top">verbose</td>
1717 <td valign="top">{True, False}</td>
1718 <td valign="top">print detailed information about the image</td>
1719 </tr>
1720
1721 <tr>
1722 <td valign="top">virtual-pixel</td>
1723 <td valign="top">{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
1724 <td valign="top">the virtual pixel method</td>
1725 </tr>
1726
1727 <tr>
1728 <td valign="top">white-point</td>
1729 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1730 <td valign="top">chromaticity white point (e.g. 0.3127, 0.329)</td>
1731 </tr>
1732 </tbody>
1733</table>
1734
1735<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>
1736
1737<p>SetAttribute() is an alias for method Set().</p>
1738
1739<p>Most of the attributes listed above have an analog in
1740<a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
1741
1742</div>
1743
cristydcca3fa2010-12-29 21:50:07 +00001744<h2><a id="get-attribute"></a>Get an Image Attribute</h2>
cristy3ed852e2009-09-05 21:47:34 +00001745<div class="doc-section">
1746
1747<p>Use method Get() to get an image attribute. For example,</p>
1748
1749<pre class="code">
1750 ($a, $b, $c) = $image-&gt;Get('colorspace', 'magick', 'adjoin');
1751 $width = $image-&gt;[3]-&gt;Get('columns');
1752</pre>
1753
1754<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>
1755
1756<table class="doc">
1757 <caption>Image Attributes</caption>
1758 <tbody>
1759 <tr>
1760 <th>Attribute</th>
1761 <th>Values</th>
1762 <th style="width: 60%">Description</th>
1763 </tr>
1764
1765 <tr>
1766 <td valign="top">area</td>
1767 <td valign="top"><i>integer</i></td>
1768 <td valign="top">current area resource consumed</td>
1769 </tr>
1770
1771 <tr>
1772 <td valign="top">base-columns</td>
1773 <td valign="top"><i>integer</i></td>
1774 <td valign="top">base image width (before transformations)</td>
1775 </tr>
1776
1777 <tr>
1778 <td valign="top">base-filename</td>
1779 <td valign="top"><i>string</i></td>
1780 <td valign="top">base image filename (before transformations)</td>
1781 </tr>
1782
1783 <tr>
1784 <td valign="top">base-rows</td>
1785 <td valign="top"><i>integer</i></td>
1786 <td valign="top">base image height (before transformations)</td>
1787 </tr>
1788
1789 <tr>
1790 <td valign="top">class</td>
1791 <td valign="top">{Direct, Pseudo}</td>
1792 <td valign="top">image class</td>
1793 </tr>
1794
1795 <tr>
1796 <td valign="top">colors</td>
1797 <td valign="top"><i>integer</i></td>
1798 <td valign="top">number of unique colors in the image</td>
1799 </tr>
1800
1801 <tr>
1802 <td valign="top">columns</td>
1803 <td valign="top"><i>integer</i></td>
1804 <td valign="top">image width</td>
1805 </tr>
1806
1807 <tr>
1808 <td valign="top">copyright</td>
1809 <td valign="top"><i>string</i></td>
1810 <td valign="top">get PerlMagick's copyright</td>
1811 </tr>
1812
1813 <tr>
1814 <td valign="top">directory</td>
1815 <td valign="top"><i>string</i></td>
1816 <td valign="top">tile names from within an image montage</td>
1817 </tr>
1818
1819 <tr>
1820 <td valign="top">elapsed-time</td>
1821 <td valign="top"><i>double</i></td>
1822 <td valign="top">elapsed time in seconds since the image was created</td>
1823 </tr>
1824
1825 <tr>
1826 <td valign="top">error</td>
1827 <td valign="top"><i>double</i></td>
1828 <td valign="top">the mean error per pixel computed with methods Compare() or Quantize()</td>
1829 </tr>
1830
1831 <tr>
1832 <td valign="top">bounding-box</td>
1833 <td valign="top"><i>string</i></td>
1834 <td valign="top">image bounding box</td>
1835 </tr>
1836
1837 <tr>
1838 <td valign="top">disk</td>
1839 <td valign="top"><i>integer</i></td>
1840 <td valign="top">current disk resource consumed</td>
1841 </tr>
1842
1843 <tr>
1844 <td valign="top">filesize</td>
1845 <td valign="top"><i>integer</i></td>
1846 <td valign="top">number of bytes of the image on disk</td>
1847 </tr>
1848
1849 <tr>
1850 <td valign="top">format</td>
1851 <td valign="top"><i>string</i></td>
1852 <td valign="top">get the descriptive image format</td>
1853 </tr>
1854
1855 <tr>
1856 <td valign="top">geometry</td>
1857 <td valign="top"><i>string</i></td>
1858 <td valign="top">image geometry</td>
1859 </tr>
1860
1861 <tr>
1862 <td valign="top">height</td>
1863 <td valign="top"><i>integer</i></td>
1864 <td valign="top">the number of rows or height of an image</td>
1865 </tr>
1866
1867 <tr>
1868 <td valign="top">id</td>
1869 <td valign="top"><i>integer</i></td>
1870 <td valign="top">ImageMagick registry id</td>
1871 </tr>
1872
1873 <tr>
1874 <td valign="top">mean-error</td>
1875 <td valign="top"><i>double</i></td>
1876 <td valign="top">the normalized mean error per pixel computed with methods Compare() or Quantize()</td>
1877 </tr>
1878
1879 <tr>
1880 <td valign="top">map</td>
1881 <td valign="top"><i>integer</i></td>
1882 <td valign="top">current memory-mapped resource consumed</td>
1883 </tr>
1884
1885 <tr>
1886 <td valign="top">matte</td>
1887 <td valign="top">{True, False}</td>
1888 <td valign="top">whether or not the image has a matte channel</td>
1889 </tr>
1890
1891 <tr>
1892 <td valign="top">maximum-error</td>
1893 <td valign="top"><i>double</i></td>
1894 <td valign="top">the normalized max error per pixel computed with methods Compare() or Quantize()</td>
1895 </tr>
1896
1897 <tr>
1898 <td valign="top">memory</td>
1899 <td valign="top"><i>integer</i></td>
1900 <td valign="top">current memory resource consumed</td>
1901 </tr>
1902
1903 <tr>
1904 <td valign="top">mime</td>
1905 <td valign="top"><i>string</i></td>
1906 <td valign="top">MIME of the image format</td>
1907 </tr>
1908
1909 <tr>
1910 <td valign="top">montage</td>
1911 <td valign="top"><i>geometry</i></td>
1912 <td valign="top">tile size and offset within an image montage</td>
1913 </tr>
1914
1915 <tr>
1916 <td valign="top">page.x</td>
1917 <td valign="top"><i>integer</i></td>
1918 <td valign="top">x offset of image virtual canvas</td>
1919 </tr>
1920
1921 <tr>
1922 <td valign="top">page.y</td>
1923 <td valign="top"><i>integer</i></td>
1924 <td valign="top">y offset of image virtual canvas</td>
1925 </tr>
1926
1927 <tr>
1928 <td valign="top">rows</td>
1929 <td valign="top"><i>integer</i></td>
1930 <td valign="top">the number of rows or height of an image</td>
1931 </tr>
1932
1933 <tr>
1934 <td valign="top">signature</td>
1935 <td valign="top"><i>string</i></td>
1936 <td valign="top">SHA-256 message digest associated with the image pixel stream</td>
1937 </tr>
1938
1939 <tr>
1940 <td valign="top">taint</td>
1941 <td valign="top">{True, False}</td>
1942 <td valign="top">True if the image has been modified</td>
1943 </tr>
1944
1945 <tr>
1946 <td valign="top">total-ink-density</td>
1947 <td valign="top"><i>double</i></td>
1948 <td valign="top">returns the total ink density for a CMYK image</td>
1949 </tr>
1950
1951 <tr>
1952 <td valign="top">transparent-color</td>
1953 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1954 <td valign="top">set the image transparent color</td>
1955 </tr>
1956
1957 <tr>
1958 <td valign="top">user-time</td>
1959 <td valign="top"><i>double</i></td>
1960 <td valign="top">user time in seconds since the image was created</td>
1961 </tr>
1962
1963 <tr>
1964 <td valign="top">version</td>
1965 <td valign="top"><i>string</i></td>
1966 <td valign="top">get PerlMagick's version</td>
1967 </tr>
1968
1969 <tr>
1970 <td valign="top">width</td>
1971 <td valign="top"><i>integer</i></td>
1972 <td valign="top">the number of columns or width of an image</td>
1973 </tr>
1974
1975 <tr>
1976 <td valign="top">x-resolution</td>
1977 <td valign="top"><i>integer</i></td>
1978 <td valign="top">x resolution of the image</td>
1979 </tr>
1980
1981 <tr>
1982 <td valign="top">y-resolution</td>
1983 <td valign="top"><i>integer</i></td>
1984 <td valign="top">y resolution of the image</td>
1985 </tr>
1986 </tbody>
1987</table>
1988
1989<p>GetAttribute() is an alias for method Get().</p>
1990
1991<p>Most of the attributes listed above have an analog in
1992<a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
1993
1994</div>
1995
cristydcca3fa2010-12-29 21:50:07 +00001996<h2><a id="compare"></a>Compare an Image to its Reconstruction</h2>
cristy3ed852e2009-09-05 21:47:34 +00001997<div class="doc-section">
1998</div>
1999
2000<p>Mathematically and visually annotate the difference between an image and its reconstruction with the Compare() method. The method supports these parameters:</p>
2001
2002<table class="doc">
2003 <caption>Compare Parameters</caption>
2004 <tbody>
2005 <tr>
2006 <th>Parameter</th>
2007 <th style="width: 40%">Values</th>
2008 <th style="width: 40%">Description</th>
2009 </tr>
2010
2011 <tr>
2012 <td valign="top">channel</td>
2013 <td valign="top"><i>double</i></td>
2014 <td valign="top">select image channels, the default is all channels except alpha.</td>
2015 </tr>
2016
2017 <tr>
2018 <td valign="top">fuzz</td>
2019 <td valign="top"><i>double</i></td>
2020 <td valign="top">colors within this distance are considered equal</td>
2021 </tr>
2022
2023 <tr>
2024 <td valign="top">image</td>
2025 <td valign="top"><i>image-reference</i></td>
2026 <td valign="top">the image reconstruction</td>
2027 </tr>
2028
2029 <tr>
2030 <td valign="top">metric</td>
2031 <td valign="top">AE, MAE, MEPP, MSE, PAE, PSNR, RMSE</td>
2032 <td valign="top">measure differences between images with this metric</td>
2033 </tr>
2034 </tbody>
2035</table>
2036
2037<p>In this example, we compare the ImageMagick logo to a sharpened reconstruction:</p>
2038
2039<pre class="code">
2040 use Image::Magick;
2041
2042 $logo=Image::Magick->New();
2043 $logo->Read('logo:');
2044 $sharp=Image::Magick->New();
2045 $sharp->Read('logo:');
2046 $sharp->Sharpen('0x1');
2047 $difference=$logo->Compare(image=>$sharp, metric=>'rmse');
2048 print $difference->Get('error'), "\n";
2049 $difference->Display();
2050</pre>
2051
2052<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>
2053
cristydcca3fa2010-12-29 21:50:07 +00002054<h2><a id="montage"></a>Create an Image Montage</h2>
cristy3ed852e2009-09-05 21:47:34 +00002055<div class="doc-section">
2056
2057<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>
2058
2059<pre class="code">
2060 $image-&gt;Montage(geometry=&gt;'160x160', tile=&gt;'2x2', texture=&gt;'granite:');
2061</pre>
2062
2063<p>And here is a list of Montage() parameters you can set:</p>
2064
2065<table class="doc">
2066 <caption>Montage Parameters</caption>
2067 <tbody>
2068 <tr>
2069 <th>Parameter</th>
2070 <th style="width: 40%">Values</th>
2071 <th style="width: 40%">Description</th>
2072 </tr>
2073
2074 <tr>
2075 <td valign="top">background</td>
2076 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
2077 <td valign="top">background color name</td>
2078 </tr>
2079
2080 <tr>
2081 <td valign="top">border</td>
2082 <td valign="top"><i>integer</i></td>
2083 <td valign="top">image border width</td>
2084 </tr>
2085
2086 <tr>
2087 <td valign="top">filename</td>
2088 <td valign="top"><i>string</i></td>
2089 <td valign="top">name of montage image</td>
2090 </tr>
2091
2092 <tr>
2093 <td valign="top">fill</td>
2094 <td valign="top"><a href="../www/color.html">color name</a></td>
2095 <td valign="top">fill color for annotations</td>
2096 </tr>
2097
2098 <tr>
2099 <td valign="top">font</td>
2100 <td valign="top"><i>string</i></td>
2101 <td valign="top">X11 font name</td>
2102 </tr>
2103
2104 <tr>
2105 <td valign="top">frame</td>
2106 <td valign="top"><i>geometry</i></td>
2107 <td valign="top">surround the image with an ornamental border</td>
2108 </tr>
2109
2110 <tr>
2111 <td valign="top">geometry</td>
2112 <td valign="top"><i>geometry</i></td>
2113 <td valign="top">preferred tile and border size of each tile of the composite
2114image (e.g. 120x120+4+3>)</td>
2115 </tr>
2116
2117 <tr>
2118 <td valign="top">gravity</td>
2119 <td valign="top">NorthWest, North, NorthEast, West, Center, East, SouthWest,
2120South, SouthEast</td>
2121 <td valign="top">direction image gravitates to within a tile</td>
2122 </tr>
2123
2124 <tr>
2125 <td valign="top">label</td>
2126 <td valign="top"><i>string</i></td>
2127 <td valign="top">assign a label to an image</td>
2128 </tr>
2129
2130 <tr>
2131 <td valign="top">mode</td>
2132 <td valign="top">Frame, Unframe, Concatenate</td>
2133 <td valign="top">thumbnail framing options</td>
2134 </tr>
2135
2136 <tr>
2137 <td valign="top">pointsize</td>
2138 <td valign="top"><i>integer</i></td>
2139 <td valign="top">pointsize of the Postscript or TrueType font</td>
2140 </tr>
2141
2142 <tr>
2143 <td valign="top">shadow</td>
2144 <td valign="top">{True, False}</td>
2145 <td valign="top">add a shadow beneath a tile to simulate depth</td>
2146 </tr>
2147
2148 <tr>
2149 <td valign="top">stroke</td>
2150 <td valign="top"><a href="../www/color.html">color name</a></td>
2151 <td valign="top">stroke color for annotations</td>
2152 </tr>
2153
2154 <tr>
2155 <td valign="top">texture</td>
2156 <td valign="top"><i>string</i></td>
2157 <td valign="top">name of texture to tile onto the image background</td>
2158 </tr>
2159
2160 <tr>
2161 <td valign="top">tile</td>
2162 <td valign="top"><i>geometry</i></td>
2163 <td valign="top">the number of tiles per row and page (e.g. 6x4)</td>
2164 </tr>
2165
2166 <tr>
2167 <td valign="top">title</td>
2168 <td valign="top">string</td>
2169 <td valign="top">assign a title to the image montage</td>
2170 </tr>
2171
2172 <tr>
2173 <td valign="top">transparent</td>
2174 <td valign="top"><i>string</i></td>
2175 <td valign="top">make this color transparent within the image</td>
2176 </tr>
2177 </tbody>
2178</table>
2179
2180<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>
2181
2182<p>MontageImage() is an alias for method Montage().</p>
2183
2184<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>
2185
2186</div>
2187
cristydcca3fa2010-12-29 21:50:07 +00002188<h2><a id="blobs"></a>Working with Blobs</h2>
cristy3ed852e2009-09-05 21:47:34 +00002189<div class="doc-section">
2190
2191<p>A blob contains data that directly represent a particular image
2192format in memory instead of on disk. PerlMagick supports
2193blobs 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>
2194
2195<table class="doc">
2196 <caption>Blob Methods</caption>
2197 <tbody>
2198 <tr>
2199 <th>Method</th>
2200 <th>Parameters</th>
2201 <th>Return Value</th>
2202 <th>Description</th>
2203 </tr>
2204
2205 <tr>
2206 <td valign="top">ImageToBlob</td>
2207 <td valign="top">any image <a href="#set-attribute">attribute</a></td>
2208 <td valign="top">an array of image data in the respective image format</td>
2209 <td valign="top">convert an image or image sequence to an array of blobs</td>
2210 </tr>
2211
2212 <tr>
2213 <td valign="top">BlobToImage</td>
2214 <td valign="top">one or more blobs</td>
2215 <td valign="top">the number of blobs converted to an image</td>
2216 <td valign="top">convert one or more blobs to an image</td>
2217 </tr>
2218 </tbody>
2219</table>
2220
2221<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>
2222
2223<pre class="code">
2224 @blobs = $image-&gt;ImageToBlob();
2225 open(DISPLAY,"| display -") || die;
2226 binmode DISPLAY;
2227 print DISPLAY $blobs[0];
2228 close DISPLAY;
2229</pre>
2230
2231<p>Method BlobToImage() returns an image or image sequence converted from the supplied blob:</p>
2232
2233<pre class="code">
2234 @blob=$db-&gt;GetImage();
2235 $image=Image::Magick-&gt;new(magick=&gt;'jpg');
2236 $image-&gt;BlobToImage(@blob);
2237</pre>
2238
2239</div>
2240
cristydcca3fa2010-12-29 21:50:07 +00002241<h2><a id="direct-access"></a>Direct-access to Image Pixels</h2>
cristy3ed852e2009-09-05 21:47:34 +00002242<div class="doc-section">
2243
2244<p>Use these methods to obtain direct access to the image pixels:</p>
2245
2246<table class="doc">
2247<caption>Direct-access to Image Pixels</caption>
2248<tbody>
2249 <tr>
2250 <th>Method</th>
2251 <th>Parameters</th>
2252 <th style="width: 50%">Description</th>
2253 </tr>
2254
2255 <tr>
2256 <td valign="top">GetAuthenticPixels</td>
2257 <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>
2258 <td valign="top">return image pixels as a C pointer</td>
2259 </tr>
2260
2261 <tr>
2262 <td valign="top">GetVirtualPixels</td>
2263 <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>
2264 <td valign="top">return image pixels as a const C pointer</td>
2265 </tr>
2266
2267 <tr>
2268 <td valign="top">GetAuthenticIndexQueue</td>
cristy48dd1af2009-10-02 01:21:56 +00002269 <td valign="top"></td>
cristy3ed852e2009-09-05 21:47:34 +00002270 <td valign="top">return image indexes as a C pointer</td>
2271 </tr>
2272
2273 <tr>
2274 <td valign="top">GetVirtualIndexQueue</td>
cristy48dd1af2009-10-02 01:21:56 +00002275 <td valign="top"></td>
cristy3ed852e2009-09-05 21:47:34 +00002276 <td valign="top">return image indexes as a const C pointer</td>
2277 </tr>
2278
2279 <tr>
2280 <td valign="top">SyncAuthenticPixels</td>
2281 <td valign="top"></td>
2282 <td valign="top">sync image pixels to pixel cache</td>
2283 </tr>
2284
2285</tbody>
2286</table>
2287
2288</div>
2289
cristydcca3fa2010-12-29 21:50:07 +00002290<h2><a id="miscellaneous"></a>Miscellaneous Methods</h2>
cristy3ed852e2009-09-05 21:47:34 +00002291<div class="doc-section">
2292
2293<p>The Append() method append a set of images. For example,</p>
2294
2295<pre class="code">
2296 $p = $image-&gt;Append(stack=&gt;{true,false});
2297</pre>
2298
2299<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>
2300
cristy3ed852e2009-09-05 21:47:34 +00002301<p>The Clone() method copies a set of images. For example,</p>
2302
2303<pre class="code">
2304 $q = $p-&gt;Clone();
2305</pre>
2306
2307<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>
2308
cristy63fed272010-03-07 19:08:45 +00002309<p>The EvaluateImages() method applies an arithemtic, logical or relational expression to a set of images. For example,</p>
2310
2311<pre class="code">
2312 $p = $image-&gt;EvaluateImages('mean');
2313</pre>
2314
2315<p>averages all the images associated with object <kbd>$image</kbd>.</p>
2316
cristy7396d882010-01-27 02:37:56 +00002317<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>
2318
2319<pre class="code">
2320 @features = $image-&gt;Features(1);
2321</pre>
2322
2323<p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p>
2324
cristy3ed852e2009-09-05 21:47:34 +00002325<p>The Flatten() method flattens a set of images and returns it. For example,</p>
2326
2327<pre class="code">
2328 $p = $images-&gt;Flatten(background=&gt;'none');
2329 $p-&gt;Write('flatten.png');
2330</pre>
2331
2332<p>The sequence of images is replaced by a single image created by composing each image after the first over the first image.</p>
2333
2334<p>The Fx() method applies a mathematical expression to a set of images and returns the results. For example,</p>
2335
2336<pre class="code">
2337 $p = $image-&gt;Fx(expression=&gt;'(g+b)/2.0',channel=&gt;'red');
2338 $p-&gt;Write('fx.miff');
2339</pre>
2340
2341<p>replaces the red channel with the average of the green and blue channels.</p>
2342
2343<p>See <a href="../www/fx.html">FX, The Special Effects Image Operator</a> for a detailed discussion of this method.</p>
2344
2345<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>
2346
2347<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>
2348
2349<pre class="code">
2350 $p = $image-&gt;Morph(frames=&gt;<i>integer</i>);
2351</pre>
2352
2353<p>where <i>frames</i> is the number of in-between images to generate. The default is 1.</p>
2354
2355<p>Mosaic() creates an mosaic from an image sequence.</p>
2356
2357<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>
2358
2359<pre class="code">
2360 $image-&gt;Crop('340x256+0+0');
2361 $image-&gt;Mogrify('crop', '340x256+0+0');
2362</pre>
2363
2364<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>
2365
2366<pre class="code">
2367 $image-&gt;MogrifyRegion('100x100+40+50', 'modulate', brightness=&gt;50);
2368</pre>
2369
2370<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>
2371
2372<pre class="code">
2373 ($width, $height, $size, $format) = $image-&gt;Ping('logo.png');
2374 ($width, $height, $size, $format) = $image-&gt;Ping(file=&gt;\*IMAGE);
2375 ($width, $height, $size, $format) = $image-&gt;Ping(blob=&gt;$blob);
2376</pre>
2377
2378<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>
2379
2380<pre class="code">
2381 $preview = $image-&gt;Preview('Gamma');
2382 $preview-&gt;Display();
2383</pre>
2384
2385<p>To have full control over text positioning you need font metric information. Use</p>
2386
2387<pre class="code">
2388 ($x_ppem, $y_ppem, $ascender, $descender, $width, $height, $max_advance)
2389 = $image-&gt;QueryFontMetrics(<i>parameters</i>);
2390</pre>
2391
2392<p>Where <i>parameters</i> is any parameter of the <a href="#manipulate">Annotate</a> method. The return values are:</p>
2393
2394<ul>
2395 <li>character width</li>
2396 <li>character height</li>
2397 <li>ascender</li>
2398 <li>descender</li>
2399 <li>text width</li>
2400 <li>text height</li>
2401 <li>maximum horizontal advance</li>
2402 <li>bounds: x1</li>
2403 <li>bounds: y1</li>
2404 <li>bounds: x2</li>
2405 <li>bounds: y2</li>
2406 <li>origin: x</li>
2407 <li>origin: y</li>
2408</ul>
2409
2410<p>Use QueryMultilineFontMetrics() to get the maximum text width and height for multiple lines of text.</p>
2411
2412<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>
2413
2414<pre class="code">
2415 @colors = $image-&gt;QueryColor();
2416 ($red, $green, $blue, $opacity) = $image-&gt;QueryColor('cyan');
2417 ($red, $green, $blue, $opacity) = $image-&gt;QueryColor('#716bae');
2418</pre>
2419
2420<p>QueryColorname() accepts a color value and returns its respective name or hex value;</p>
2421
2422<pre class="code">
2423 $name = $image-&gt;QueryColorname('rgba(80,60,0,0)');
2424</pre>
2425
2426<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>
2427
2428<pre class="code">
2429 @fonts = $image-&gt;QueryFont();
2430 $weight = ($image-&gt;QueryFont('Helvetica'))[5];
2431</pre>
2432
2433<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>
2434
2435<pre class="code">
2436 @formats = $image-&gt;QueryFormat();
2437 ($adjoin, $blob_support, $raw, $decoder, $encoder, $description, $module)
2438 = $image-&gt;QueryFormat('gif');
2439</pre>
2440
2441<p>Call MagickToMime() with the image format name to get its MIME type such as <kbd>images/tiff</kbd> from <kbd>tif</kbd>.</p>
2442
2443<pre class="code">
2444 $mime = $image-&gt;MagickToMime('tif');
2445</pre>
2446
2447<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>
2448
2449<pre class="code">
2450 $image-&gt;RemoteCommand('image.jpg');
2451</pre>
2452
2453<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>
2454
2455<pre class="code">
2456 @statistics = $image-&gt;Statistics();
2457</pre>
2458
2459<p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p>
2460
2461<pre class="code">
2462 $p = $image-&gt;Transform(crop=&gt;'100x100+0+0', gravity=&gt;'Center');
2463</pre>
2464
2465<p>You can optionally add <i>Image</i> to any method name above. For example, PingImage() is an alias for method Ping().</p>
2466
2467</div>
2468
cristydcca3fa2010-12-29 21:50:07 +00002469<h2><a id="exceptions"></a>Handling Exceptions</h2>
cristy3ed852e2009-09-05 21:47:34 +00002470<div class="doc-section">
2471
2472<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>
2473
2474<p>Methods which return a number (e.g. Read(), Write()):</p>
2475
2476<pre class="code">
2477 $x = $image-&gt;Read(...);
2478 warn "$x" if "$x"; # print the error message
2479 $x =~ /(\d+)/;
2480 print $1; # print the error number
2481 print 0+$x; # print the number of images read
2482</pre>
2483
2484<p>Methods which operate on an image (e.g. Resize(), Crop()):</p>
2485
2486<pre class="code">
2487 $x = $image-&gt;Crop(...);
2488 warn "$x" if "$x"; # print the error message
2489 $x =~ /(\d+)/;
2490 print $1; # print the error number
2491</pre>
2492
cristy63fed272010-03-07 19:08:45 +00002493<p>Methods which return images (EvaluateSequence(), Montage(), Clone()) should be checked for errors this way:</p>
cristy3ed852e2009-09-05 21:47:34 +00002494
2495<pre class="code">
2496 $x = $image-&gt;Montage(...);
2497 warn "$x" if !ref($x); # print the error message
2498 $x =~ /(\d+)/;
2499 print $1; # print the error number
2500</pre>
2501
2502<p>Here is an example error message:</p>
2503
2504<pre class="code">
2505 Error 400: Memory allocation failed
2506</pre>
2507
2508<p>Review the complete list of <a href="../www/exception.html">error and warning codes</a>.</p>
2509
2510<p>The following illustrates how you can use a numeric status code:</p>
2511
2512<pre class="code">
2513 $x = $image-&gt;Read('rose.png');
2514 $x =~ /(\d+)/;
2515 die "unable to continue" if ($1 == ResourceLimitError);
2516</pre>
2517
2518</div>
2519
cristydcca3fa2010-12-29 21:50:07 +00002520<h2><a id="constants"></a>Constants</h2>
cristy3ed852e2009-09-05 21:47:34 +00002521<div class="doc-section">
2522
2523<p>PerlMagick includes these constants:</p>
2524
2525<pre class="text">
2526 BlobError
2527 BlobWarning
2528 CacheError
2529 CacheWarning
2530 CoderError
2531 CoderWarning
2532 ConfigureError
2533 ConfigureWarning
2534 CorruptImageError
2535 CorruptImageWarning
2536 DelegateError
2537 DelegateWarning
2538 DrawError
2539 DrawWarning
2540 ErrorException
2541 FatalErrorException
2542 FileOpenError
2543 FileOpenWarning
2544 ImageError
2545 ImageWarning
2546 MissingDelegateError
2547 MissingDelegateWarning
2548 ModuleError
2549 ModuleWarning
2550 Opaque
2551 OptionError
2552 OptionWarning
2553 QuantumDepth
2554 QuantumRange
2555 RegistryError
2556 RegistryWarning
2557 ResourceLimitError
2558 ResourceLimitWarning
2559 StreamError
2560 StreamWarning
2561 Success
2562 Transparent
2563 TypeError
2564 TypeWarning
2565 WarningException
2566 XServerError
2567 XServerWarning
2568</pre>
2569
2570<p>You can access them like this:</p>
2571
2572<pre class="code">
2573 Image::Magick-&gt;QuantumDepth
2574</pre>
2575
2576</div>
cristy3eaa0ef2010-03-06 20:35:26 +00002577
2578</div>
2579
2580<div id="linkbar">
cristyce69bb02010-07-27 19:49:46 +00002581 <span id="linkbar-west">&nbsp;</span>
cristy3eaa0ef2010-03-06 20:35:26 +00002582 <span id="linkbar-center">
2583 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
cristya8902942010-07-30 00:49:52 +00002584 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
cristy3eaa0ef2010-03-06 20:35:26 +00002585 </span>
2586 <span id="linkbar-east">&nbsp;</span>
2587 </div>
2588 <div class="footer">
cristy7e41fe82010-12-04 23:12:08 +00002589 <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>
cristy3eaa0ef2010-03-06 20:35:26 +00002590 <span id="footer-east"> <a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
2591 </div>
2592 <div style="clear: both; margin: 0; width: 100%; "></div>
cristya8902942010-07-30 00:49:52 +00002593 <script type="text/javascript">
2594 var _gaq = _gaq || [];
2595 _gaq.push(['_setAccount', 'UA-17690367-1']);
2596 _gaq.push(['_trackPageview']);
2597
2598 (function() {
2599 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
2600 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
2601 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
2602 })();
2603 </script>
cristy3eaa0ef2010-03-06 20:35:26 +00002604</body>
2605</html>