1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
\r
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
\r
3 <html version="-//W3C//DTD XHTML 1.1//EN"
\r
4 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
\r
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\r
6 xsi:schemaLocation="http://www.w3.org/1999/xhtml
\r
7 http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
\r
9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
\r
10 <meta name="google-site-verification" content="MxsMq6bdLOx0KSuz1MY6yG9ZTIJ7_7DVRfl5NCAT5Yg"/>
\r
11 <title>ImageMagick: PerlMagick, Perl API for ImageMagick</title>
12 <meta http-equiv="Content-Language" content="en-US"/>
13 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
15 <meta name="Application-name" content="ImageMagick"/>
16 <meta name="Description" content="Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition resize, rotate, shear, distort and transform images automagically."/>
17 <meta name="Application-url" content="http://www.imagemagick.org"/>
18 <meta name="Generator" content="PHP"/>
19 <meta name="Keywords" content="perlmagick, perl, api, for, imagemagick, ImageMagick, PerlMagick, image processing, OpenMP, software development library, image, photo, software, Magick++, MagickWand"/>
20 <meta name="Rating" content="GENERAL"/>
21 <meta name="Robots" content="INDEX, FOLLOW"/>
22 <meta name="Generator" content="ImageMagick Studio LLC"/>
23 <meta name="Author" content="ImageMagick Studio LLC"/>
24 <meta name="Revisit-after" content="2 DAYS"/>
25 <meta name="Resource-type" content="document"/>
26 <meta name="Copyright" content="Copyright (c) 1999-2012 ImageMagick Studio LLC"/>
27 <meta name="Distribution" content="Global"/>
28 <link rel="icon" href="../images/wand.png"/>
29 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"/>
30 <link rel="canonical" href="http://www.imagemagick.org" />
\r
31 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
\r
32 <!-- Add jQuery library -->
\r
33 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
\r
35 <!-- Optionaly include easing and/or mousewheel plugins -->
\r
36 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.easing-1.3.pack.js"></script>
\r
37 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>
\r
39 <!-- Add fancyBox -->
\r
40 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/jquery.fancybox.css?v=2.0.3" type="text/css" media="screen" />
\r
41 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.fancybox.pack.js?v=2.0.3"></script>
\r
43 <!-- Optionaly include button and/or thumbnail helpers -->
\r
44 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.css?v=2.0.3" type="text/css" media="screen" />
\r
45 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.js?v=2.0.3"></script>
\r
47 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.css?v=2.0.3" type="text/css" media="screen" />
\r
48 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.js?v=2.0.3"></script>
\r
49 <script type="text/javascript">
\r
50 $(document).ready(function() {
\r
51 $(".fancybox").fancybox();
\r
54 <!-- ImageMagick style -->
\r
55 <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
\r
56 <style type="text/css" media="all">
\r
57 @import url("../www/magick.css");
\r
61 <body id="www-imagemagick-org">
\r
62 <div class="titlebar">
\r
63 <div style="margin: 17px auto; float: left;">
\r
64 <script type="text/javascript">
\r
66 google_ad_client = "pub-3129977114552745";
\r
67 google_ad_slot = "5439289906";
\r
68 google_ad_width = 728;
\r
69 google_ad_height = 90;
\r
72 <script type="text/javascript"
\r
73 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
\r
76 <a href="http://www.imagemagick.org/discourse-server/">
\r
77 <img src="../images/logo.jpg"
\r
78 alt="ImageMagick Logo"
\r
79 style="width: 123px; height: 118px; border: 0px; float: right;" /></a>
\r
80 <a href="../index.html">
\r
81 <img src="../images/sprite.jpg"
\r
82 alt="ImageMagick Sprite"
\r
83 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
\r
86 <div class="westbar">
\r
89 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
92 <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
95 <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
98 <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
101 <a title="Binary Release: iOS" href="../www/binary-releases.html#iOS">iOS</a>
104 <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
106 <div class="sep"></div>
\r
108 <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
111 <a title="Command-line Tools: Processing" href="../www/command-line-processing.html">Processing</a>
114 <a title="Command-line Tools: Options" href="../www/command-line-options.html">Options</a>
117 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
120 <a title="Program Interfaces" href="../www/api.html">Program Interfaces</a>
123 <a title="Program Interface: MagickWand" href="../www/magick-wand.html">MagickWand</a>
126 <a title="Program Interface: MagickCore" href="../www/magick-core.html">MagickCore</a>
129 <a title="Program Interface: PerlMagick" href="../www/perl-magick.html">PerlMagick</a>
132 <a title="Program Interface: Magick++" href="../www/magick++.html">Magick++</a>
134 <div class="sep"></div>
\r
136 <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
139 <a title="Install from Source: Unix" href="../www/install-source.html#unix">Unix</a>
142 <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
145 <a title="Resources" href="../www/resources.html">Resources</a>
148 <a title="Architecture" href="../www/architecture.html">Architecture</a>
151 <a title="Download" href="../www/download.html">Download</a>
153 <div class="sep"></div>
\r
155 <a title="Search" href="../www/search.html">Search</a>
157 <div class="sep"></div>
\r
159 <a title="Site Map" href="../www/sitemap.html">Site Map</a>
162 <a title="Site Map: Links" href="../www/links.html">Links</a>
164 <div class="sep"></div>
\r
166 <a rel="follow" title="Sponsors" href="../www/sponsors.html">Sponsors:</a>
168 <a href="http://www.networkredux.com"> <img src="../images/networkredux.png" width="140" height="31" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a>
169 <a href="http://www.dinodirect.com/ipads-tablets/"> <img src="../images/dino-direct.jpg" width="140" height="90" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a><!-- 201204010120 mickey@163... -->
170 <div class="sponsbox">
171 <div class="sponsor">
172 <a rel="follow" title="Android Tablet" href="http://www.dinodirect.com/ipads-tablets/">Android Tablet</a><!-- 201204010120 mickey@163... -->
174 <div class="sponsor">
175 <a rel="follow" title="Sponsor: Web Hosting" href="http://www.micfo.com">Web Hosting</a><!-- 209901010090s golestan -->
177 <div class="sponsor">
178 <a rel="follow" title="Sponsor: Autos Part" href="http://www.pkwteile.de/autoteile">Autos Part</a><!-- 201203010270 info@pkwte... -->
180 <div class="sponsor">
181 <a rel="follow" title="Sponsor: Web Site Hosting" href="http://webhostinggeeks.com">Web Site Hosting</a><!-- 201302010900 funds@enmob... -->
183 <div class="sponsor">
184 <a rel="follow" title="Sponsor: Tenant Check" href="http://www.rentmethod.com/">Tenant Check</a><!-- 201203010090 chris@rentm... -->
186 <div class="sponsor">
187 <a rel="follow" title="Sponsor: VPS" href="http://www.interdominios.com/vps">VPS</a><!-- 201204010090 barsh@inter... -->
189 <div class="sponsor">
190 <a rel="follow" title="Sponsor: Premium Quality Stock Photos" href="http://www.f1online.pro/en/">Premium Quality Stock Photos</a><!-- 2012080100540 ... -->
192 <div class="sponsor">
193 <a rel="follow" title="Sponsor: Search engine optimisation" href="http://www.seomoves.com.au">Search engine optimisation</a><!-- 201301010090s jen@seo lowprofilelinks -->
195 <div class="sponsor">
196 <a rel="follow" title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 2012070100250 ... -->
198 <div class="sponsor">
199 <a rel="follow" title="Sponsor: Managed Server" href="http://www.robhost.de">Managed Server</a><!-- 201210010720 klikics... -->
201 <div class="sponsor">
202 <a rel="follow" title="Sponsor: Stock Photography" href="http://www.fotosearch.com/">Stock Photography</a><!-- 2012040100250 ... -->
204 <div class="sponsor">
205 <a rel="follow" title="Sponsor: Autoteile" href="http://www.q11-shop.de">Autoteile</a><!-- 201205010540 suvalj -->
207 <div class="sponsor">
208 <a rel="follow" title="Sponsor: Royalty Free Stock Images" href="http://www.canstockphoto.com/">Royalty Free Stock Images</a><!-- 2012050100360 support@can -->
210 <div class="sponsor">
211 <a rel="follow" title="Sponsor: Web Hosting Reviews" href="http://www.webhostingsecretrevealed.com">Web Hosting Secret Revealed</a><!-- 201204010540 iamchee jerry -->
213 <div class="sponsor">
214 <a rel="follow" title="Sponsor: Druckerei" href="http://www.allesdruck.de">Druckerei</a><!-- 201303011500 r.leo -->
216 <div class="sponsor">
217 <a rel="follow" title="Sponsor: Turbolader Online kaufen" href="http://www.autoteile-carparts.de">Turbolader Online kaufen</a><!-- 2012050100150 t.temurbas...-->
219 <div class="sponsor">
220 <a rel="follow" title="Sponsor: Web Hosting Reviews" href="http://www.webhostingreviewz.com">Web Hosting Reviews</a><!-- 2012040100030 Soft Tec-->
226 <div class="eastbar">
\r
227 <div class="g-plusone" data-size="standard" data-count="false"></div>
\r
228 <script type="text/javascript">
\r
234 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
\r
235 po.src = 'https://apis.google.com/js/plusone.js';
\r
236 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
\r
244 <h1>PerlMagick API</h1>
245 <p class="navigation-index">[<a href="#installation">Installation</a> • <a href="#overview">Overview</a> • <a href="#example">Example Script</a> • <a href="#read">Read or Write an Image</a> • <a href="#manipulate">Manipulate an Image</a> • <a href="#set-attribute">Set an Image Attribute</a> • <a href="#get-attribute">Get an Image Attribute</a> • <a href="#compare">Compare an Image to its Reconstruction</a> • <a href="#montage">Create an Image Montage</a> • <a href="#blobs">Working with Blobs</a> • <a href="#direct-access">Direct-access to Image Pixels</a> • <a href="#miscellaneous">Miscellaneous Methods</a> • <a href="#exceptions">Handling Exceptions</a>• <a href="#constants">Constant</a> ]</p>
247 <div class="doc-section">
248 <a id="introduction"></a>
249 <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>
251 <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>
253 <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>
256 <h2><a id="installation"></a>Installation</h2>
257 <div class="doc-section">
261 <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>
263 <p>ImageMagick must already be installed on your system. Next, get
264 the <a href="../www/download.html">PerlMagick</a> distribution corresponding to the installed ImageMagick distribution
265 (e.g., PerlMagick 6.75 for
266 ImageMagick 6.7.5) and unpack it as shown below:</p>
268 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>tar xvfz PerlMagick-6.75.tar.gz</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>cd PerlMagick</span></p>
269 <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>
271 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>perl Makefile.PL</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>make</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>make install</span></p>
272 <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>
274 <p><b>Windows XP / Windows 2000</b></p>
276 <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>
280 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>cd PerlMagick</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>perl Makefile.nt</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>nmake</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>nmake install</span></p>
281 <p>See the <a href="http://www.dylanbeattie.net/magick/">PerlMagick Windows HowTo</a> page for further installation instructions.</p>
283 <p><b>Running the Regression Tests</b></p>
285 <p>To verify a correct installation, type</p>
287 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>make test</span></p>
288 <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>
290 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>cd demo</span><span class='crtout'></span><span class="crtprompt"> $ </span><span class='crtin'>make</span></p>
291 <p>You are now ready to utilize the PerlMagick methods from within your Perl scripts.</p>
295 <h2><a id="overview"></a>Overview</h2>
296 <div class="doc-section">
298 <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>
303 $image=Image::Magick->new;
306 <p>The new() method takes the same parameters as <a href="#set-attribute">SetAttribute</a> . For example,</p>
309 $image=Image::Magick->new(size=>'384x256');
312 <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>
314 <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>
320 <p>To delete all the images but retain the <kbd>Image::Magick</kbd> object use</p>
326 <p>and finally, to delete a single image from a multi-image sequence, use</p>
329 undef $image->[$x];
332 <p>The next section illustrates how to use various PerlMagick methods to manipulate an image sequence.</p>
334 <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>
336 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>$ENV{PATH}='/../bin:/usr/bin:/usr/local/bin';</span></p>
337 <div style="margin: auto;">
338 <h2><a id="example"></a>Example Script</h2>
341 <p>Here is an example script to get you started:</p>
344 #!/usr/local/bin/perl
345 use Image::Magick;<br />
346 my($image, $x);<br />
347 $image = Image::Magick->new;
348 $x = $image->Read('girl.png', 'logo.png', 'rose.png');
349 warn "$x" if "$x";<br />
350 $x = $image->Crop(geometry=>'100x100+100+100');
351 warn "$x" if "$x";<br />
352 $x = $image->Write('x.png');
356 <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>
359 #!/usr/local/bin/perl
360 use Image::Magick;<br />
361 my($image, $p, $q);<br />
362 $image = new Image::Magick;
363 $image->Read('x1.png');
364 $image->Read('j*.jpg');
365 $image->Read('k.miff[1, 5, 3]');
366 $image->Contrast();
367 for ($x = 0; $image->[$x]; $x++)
369 $image->[$x]->Frame('100x200') if $image->[$x]->Get('magick') eq 'GIF';
370 undef $image->[$x] if $image->[$x]->Get('columns') < 100;
373 $p->Draw(stroke=>'red', primitive=>'rectangle', points=>20,20 100,100');
374 $q = $p->Montage();
376 $q->Write('x.miff');
379 <p>Suppose you want to start out with a 100 by 100 pixel white canvas with a red pixel in the center. Try</p>
382 $image = Image::Magick->new;
383 $image->Set(size=>'100x100');
384 $image->ReadImage('canvas:white');
385 $image->Set('pixel[49,49]'=>'red');
388 <p>Here we reduce the intensity of the red component at (1,1) by half:</p>
391 @pixels = $image->GetPixel(x=>1,y=>1);
393 $image->SetPixel(x=>1,y=>1,color=>\@pixels);
396 <p>Or suppose you want to convert your color image to grayscale:</p>
399 $image->Quantize(colorspace=>'gray');
402 <p>Let's annotate an image with a Taipai TrueType font:</p>
405 $text = 'Works like magick!';
406 $image->Annotate(font=>'kai.ttf', pointsize=>40, fill=>'green', text=>$text);
409 <p>Perhaps you want to extract all the pixel intensities from an image and write them to STDOUT:</p>
412 @pixels = $image->GetPixels(map=>'I', height=>$height, width=>$width, normalize=>true);
414 print pack('B*',join('',@pixels));
417 <p>Other clever things you can do with a PerlMagick objects include</p>
420 $i = $#$p"+1"; # return the number of images associated with object p
421 push(@$q, @$p); # push the images from object p onto object q
422 @$p = (); # delete the images but not the object p
423 $p->Convolve([1, 2, 1, 2, 4, 2, 1, 2, 1]); # 3x3 Gaussian kernel
426 <div style="margin: auto;">
427 <h2><a id="read"></a>Read or Write an Image</h2>
430 <p>Use the methods listed below to either read, write, or display an image or image sequence:</p>
433 <caption>Read or Write Methods</caption>
435 <col width="20%"></col>
436 <col width="20%"></col>
437 <col width="20%"></col>
438 <col width="40%"></col>
445 <th>Return Value</th>
450 <td valign="top">Read</td>
451 <td valign="top">one or more filenames</td>
452 <td valign="top">the number of images read</td>
453 <td valign="top">read an image or image sequence</td>
457 <td valign="top">Write</td>
458 <td valign="top">filename</td>
459 <td valign="top">the number of images written</td>
460 <td valign="top">write an image or image sequence</td>
464 <td valign="top">Display</td>
465 <td valign="top">server name</td>
466 <td valign="top">the number of images displayed</td>
467 <td valign="top">display the image or image sequence to an X server</td>
471 <td valign="top">Animate</td>
472 <td valign="top">server name</td>
473 <td valign="top">the number of images animated</td>
474 <td valign="top">animate image sequence to an X server</td>
479 <p>For convenience, methods Write(), Display(), and Animate() can take any parameter that <a href="#set-attribute">SetAttribute</a> knows about. For example,</p>
482 $image->Write(filename=>'image.png', compression=>'None');
485 <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>
489 $image->Write('png:-');
492 <p>To read an image in the GIF format from a PERL filehandle, use:</p>
495 $image = Image::Magick->new;
496 open(IMAGE, 'image.gif');
497 $image->Read(file=>\*IMAGE);
501 <p>To write an image in the PNG format to a PERL filehandle, use:</p>
504 $filename = "image.png";
505 open(IMAGE, ">$filename");
506 $image->Write(file=>\*IMAGE, filename=>$filename);
510 <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>
512 <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>
518 <p>converts files image000.miff, image001.miff, etc.</p>
520 <p>You can optionally add <i>Image</i> to any method name. For example, ReadImage() is an alias for method Read().</p>
524 <h2><a id="manipulate"></a>Manipulate an Image</h2>
525 <div class="doc-section">
527 <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>
530 $image->Crop(geometry=>'100x100+10+20');
531 $image->[$x]->Frame("100x200");
534 <p>And here is a list of other image manipulation methods you can call:</p>
537 <caption>Image Manipulation Methods</caption>
541 <th style="width: 40%">Parameters</th>
542 <th style="width: 40%">Description</th>
546 <td valign="top">AdaptiveBlur</td>
547 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
548 <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>
552 <td valign="top">AdaptiveResize</td>
553 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, filter=>{Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, Sinc}, support=><i>double</i>, blur=><i>double</i></td>
554 <td valign="top">adaptively resize image using data dependant triangulation. Specify <kbd>blur</kbd> > 1 for blurry or < 1 for sharp</td>
558 <td valign="top">AdaptiveSharpen</td>
559 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
560 <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>
564 <td valign="top">AdaptiveThreshold</td>
565 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, offset=><i>integer</i></td>
566 <td valign="top">local adaptive thresholding.</td>
570 <td valign="top">AddNoise</td>
571 <td valign="top">noise=>{Uniform, Gaussian, Multiplicative, Impulse, Laplacian, Poisson}, attenuate=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
572 <td valign="top">add noise to an image</td>
576 <td valign="top">AffineTransform</td>
577 <td valign="top">affine=><i>array of float values</i>, translate=><i>float, float</i>, scale=> <i>float, float</i>, rotate=><i>float</i>, skewX=><i>float</i>, skewY=><i>float</i>, interpolate={Average, Bicubic, Bilinear, Filter, Integer, Mesh, NearestNeighbor}, background=><i><a href="../www/color.html">color name</a></i></td>
578 <td valign="top">affine transform image</td>
582 <td valign="top">Affinity</td>
583 <td valign="top">image=><i>image-handle</i>, method=>{None, FloydSteinberg, Riemersma}</td>
584 <td valign="top">choose a particular set of colors from this image</td>
588 <td valign="top">Annotate</td>
589 <td valign="top">text=><i>string</i>, font=><i>string</i>, family=><i>string</i>, style=>{Normal, Italic, Oblique, Any}, stretch=>{Normal, UltraCondensed, ExtraCondensed, Condensed, SemiCondensed, SemiExpanded, Expanded, ExtraExpanded, UltraExpanded}, weight=><i>integer</i>, pointsize=><i>integer</i>, density=><i>geometry</i>, stroke=><i><a href="../www/color.html">color name</a></i>, strokewidth=><i>integer</i>, fill=><i><a href="../www/color.html">color name</a></i>, undercolor=><i><a href="../www/color.html">color name</a></i>, kerning=><i>float</i>, geometry=><i>geometry</i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, antialias=>{true, false}, x=><i>integer</i>, y=><i>integer</i>, affine=><i>array of float values</i>, translate=><i>float, float</i>, scale=><i>float, float</i>, rotate=><i>float</i>. skewX=><i>float</i>, skewY=> <i>float</i>, align=>{Left, Center, Right}, encoding=>{UTF-8}, interline-spacing=><i>double</i>, interword-spacing=><i>double</i>, direction=>{right-to-left, left-to-right}</td>
590 <td valign="top">annotate an image with text. See <a href="#misc">QueryFontMetrics</a> to get font metrics without rendering any text.</td>
594 <td valign="top">AutoGamma</td>
595 <td valign="top">channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
596 <td valign="top">automagically adjust gamma level of image</td>
600 <td valign="top">AutoLevel</td>
601 <td valign="top">channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
602 <td valign="top">automagically adjust color levels of image</td>
606 <td valign="top">AutoOrient</td>
607 <td valign="top"><br /></td>
608 <td valign="top">automagically orient the image</td>
612 <td valign="top">BlackThreshold</td>
613 <td valign="top">threshold=><i>string</i>, , channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
614 <td valign="top">force all pixels below the threshold intensity into black</td>
618 <td valign="top">BlueShift</td>
619 <td valign="top">factor=><i>double</i>,</td>
620 <td valign="top">simulate a scene at nighttime in the moonlight. Start with a factor of 1.5.</td>
624 <td valign="top">Blur</td>
625 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
626 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td>
630 <td valign="top">Border</td>
631 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, bordercolor=><i><a href="../www/color.html">color name</a></i>, compose=>{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>
632 <td valign="top">surround the image with a border of color</td>
636 <td valign="top">Charcoal</td>
637 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i></td>
638 <td valign="top">simulate a charcoal drawing</td>
642 <td valign="top">Chop</td>
643 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i></td>
644 <td valign="top">chop an image</td>
648 <td valign="top">Clamp</td>
649 <td valign="top"><br /></td>
650 <td valign="top">restrict color values from 0 to the quantum depth.</td>
654 <td valign="top">Clip</td>
655 <td valign="top">id=><i>name</i>, inside=><i>{true, false}</i>,</td>
656 <td valign="top">apply along a named path from the 8BIM profile.</td>
660 <td valign="top">ClipMask</td>
661 <td valign="top">mask=><i>image-handle</i></td>
662 <td valign="top">clip image as defined by the image mask</td>
666 <td valign="top">Clut</td>
667 <td valign="top">image=><i>image-handle</i>, interpolate={Average, Bicubic, Bilinear, Filter, Integer, Mesh, NearestNeighbor}, channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
668 <td valign="top">apply a color lookup table to an image sequence</td>
672 <td valign="top">Coalesce</td>
673 <td valign="top"><br /></td>
674 <td valign="top">merge a sequence of images</td>
678 <td valign="top">Color</td>
679 <td valign="top">color=><i><a href="../www/color.html">color name</a></i></td>
680 <td valign="top">set the entire image to this color.</td>
684 <td valign="top">ColorDecisionList</td>
685 <td valign="top">filename=><i>string</i>,</td>
686 <td valign="top">color correct with a color decision list.</td>
690 <td valign="top">Colorize</td>
691 <td valign="top">fill=><i><a href="../www/color.html">color name</a></i>, blend=><i>string</i></td>
692 <td valign="top">colorize the image with the fill color</td>
696 <td valign="top">ColorMatrix</td>
697 <td valign="top">matrix=><i>array of float values</i></td>
698 <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>
702 <td valign="top">Comment</td>
703 <td valign="top">string</td>
704 <td valign="top">add a comment to your image</td>
708 <td valign="top">CompareLayers</td>
709 <td valign="top">method=>{any, clear, overlay}</td>
710 <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>
714 <td valign="top">Composite</td>
715 <td valign="top">image=><i>image-handle</i>, compose=>{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=><i>image-handle</i>, geometry=><i>geometry</i>, x=><i>integer</i>, y=><i>integer</i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, opacity=><i>integer</i>, tile=>{True, False}, rotate=><i>double</i>, color=><i><a href="../www/color.html">color name</a></i>, blend=><i>geometry</i>, interpolate=>{undefined, average, bicubic, bilinear, filter, integer, mesh, nearest-neighbor, spline}</td>
716 <td valign="top">composite one image onto another. Use the rotate parameter in concert with the tile parameter.</td>
720 <td valign="top">Contrast</td>
721 <td valign="top">sharpen=>{True, False}</td>
722 <td valign="top">enhance or reduce the image contrast</td>
726 <td valign="top">ContrastStretch</td>
727 <td valign="top">levels=><i>string</i>, 'black-point'=><i>double</i>, 'white-point'=><i>double</i>, channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
728 <td valign="top">improve the contrast in an image by `stretching' the range of intensity values</td>
732 <td valign="top">Convolve</td>
733 <td valign="top">coefficients=><i>array of float values</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, bias=><i>double</i></td>
734 <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>
738 <td valign="top">Crop</td>
739 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, fuzz=><i>double</i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
740 <td valign="top">crop an image</td>
744 <td valign="top">CycleColormap</td>
745 <td valign="top">amount=><i>integer</i></td>
746 <td valign="top">displace image colormap by amount</td>
750 <td valign="top">Decipher</td>
751 <td valign="top">passphrase=><i>string</i></td>
752 <td valign="top">convert cipher pixels to plain pixels</td>
756 <td valign="top">Deconstruct</td>
757 <td valign="top"><br /></td>
758 <td valign="top">break down an image sequence into constituent parts</td>
762 <td valign="top">Deskew</td>
763 <td valign="top">geometry=><i>string</i>,threshold=><i>double</i></td>
764 <td valign="top">straighten the image</td>
768 <td valign="top">Despeckle</td>
769 <td valign="top"> </td>
770 <td valign="top">reduce the speckles within an image</td>
774 <td valign="top">Difference</td>
775 <td valign="top">image=><i>image-handle</i></td>
776 <td valign="top">compute the difference metrics between two images </td>
780 <td valign="top">Distort</td>
781 <td valign="top">points=><i>array of float values</i>, method=>{Affine, AffineProjection, Bilinear, Perspective, Resize, ScaleRotateTranslate}, virtual-pixel=>{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}, best-fit=>{True, False}</td>
782 <td valign="top">distort image</td>
786 <td valign="top">Draw</td>
787 <td valign="top">primitive=>{point, line, rectangle, arc, ellipse, circle, path, polyline, polygon, bezier, color, matte, text, @<i>filename</i>}, points=><i>string</i> , method=><i>{Point, Replace, Floodfill, FillToBorder, Reset}</i>, stroke=><i><a href="../www/color.html">color name</a></i>, fill=><i><a href="../www/color.html">color name</a></i>, font=><i>string</i>, pointsize=><i>integer</i>, strokewidth=><i>float</i>, antialias=>{true, false}, bordercolor=><i><a href="../www/color.html">color name</a></i>, x=><i>float</i>, y=><i>float</i>, dash-offset=><i>float</i>, dash-pattern=><i>array of float values</i>, affine=><i>array of float values</i>, translate=><i>float, float</i>, scale=><i>float, float</i>, rotate=><i>float</i>, skewX=><i>float</i>, skewY=><i>float</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}, kerning=><i>float</i>, text=><i>string</i>, vector-graphics=><i>string</i>, interline-spacing=><i>double</i>, interword-spacing=><i>double</i>, direction=>{right-to-left, left-to-right}</td>
788 <td valign="top">annotate an image with one or more graphic primitives.</td>
792 <td valign="top">Encipher</td>
793 <td valign="top">passphrase=><i>string</i></td>
794 <td valign="top">convert plain pixels to cipher pixels</td>
798 <td valign="top">Edge</td>
799 <td valign="top">radius=><i>double</i></td>
800 <td valign="top">enhance edges within the image with a convolution filter of the given radius.</td>
804 <td valign="top">Emboss</td>
805 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i></td>
806 <td valign="top">emboss the image with a convolution filter of the given radius and standard deviation (sigma).</td>
810 <td valign="top">Enhance</td>
811 <td valign="top"><br /></td>
812 <td valign="top">apply a digital filter to enhance a noisy image</td>
816 <td valign="top">Equalize</td>
817 <td valign="top">channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}<br /></td>
818 <td valign="top">perform histogram equalization to the image</td>
822 <td valign="top">Extent</td>
823 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, fuzz=><i>double</i>, background=><i><a href="../www/color.html">color name</a></i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
824 <td valign="top">set the image size</td>
828 <td valign="top">Evaluate</td>
829 <td valign="top">value=><i>double</i>, operator=><i>{Add, And, Divide, LeftShift, Max, Min, Multiply, Or, Rightshift, Subtract, Xor}</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow} </td>
830 <td valign="top">apply an arithmetic, relational, or logical expression to the image</td>
834 <td valign="top">Filter</td>
835 <td valign="top">kernel=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, bias=><i>double</i></td>
836 <td valign="top">apply a convolution kernel to the image.</td>
840 <td valign="top">Flip</td>
841 <td valign="top"><br /></td>
842 <td valign="top">reflect the image scanlines in the vertical direction</td>
846 <td valign="top">Flop</td>
847 <td valign="top"><br /></td>
848 <td valign="top">reflect the image scanlines in the horizontal direction</td>
852 <td valign="top">FloodfillPaint</td>
853 <td valign="top">geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, x=><i>integer</i>, y=><i>integer</i> , fill=><i><a href="../www/color.html">color name</a></i>, bordercolor=><i><a href="../www/color.html">color name</a></i>, fuzz=><i>double</i>, invert=>{True, False}</td>
854 <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>
858 <td valign="top">ForwardFourierTransform</td>
859 <td valign="top">magnitude=>{True, False}</td>
860 <td valign="top">implements the forward discrete Fourier transform (DFT)</td>
864 <td valign="top">Frame</td>
865 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, inner=><i>integer</i>, outer=><i>integer</i>, fill=><i><a href="../www/color.html">color name</a></i>, compose=>{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>
866 <td valign="top">surround the image with an ornamental border</td>
870 <td valign="top">Function</td>
871 <td valign="top">parameters=><i>array of float values</i>, function=>{Sin}, virtual-pixel=>{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
872 <td valign="top">apply a function to the image</td>
876 <td valign="top">Gamma</td>
877 <td valign="top">gamma=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
878 <td valign="top">gamma correct the image</td>
882 <td valign="top">GaussianBlur</td>
883 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
884 <td valign="top">reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td>
888 <td valign="top">GetPixel</td>
889 <td valign="top">geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, normalize=>{true, false}, x=><i>integer</i>, y=><i>integer</i></td>
890 <td valign="top">get a single pixel. By default normalized pixel values are returned.</td>
894 <td valign="top">GetPixels</td>
895 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, map=><i>string</i>, normalize=>{true, false}</td>
896 <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>
900 <td valign="top">HaldClut</td>
901 <td valign="top">image=><i>image-handle</i>, channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
902 <td valign="top">apply a Hald color lookup table to an image sequence</td>
906 <td valign="top">Identify</td>
907 <td valign="top">file=><i>file</i>, features=><i>distance</i>, unique=>{True, False}</td>
908 <td valign="top">identify the attributes of an image</td>
912 <td valign="top">Implode</td>
913 <td valign="top">amount=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
914 <td valign="top">implode image pixels about the center</td>
918 <td valign="top">InverseDiscreteFourierTransform</td>
919 <td valign="top">magnitude=>{True, False}</td>
920 <td valign="top">implements the inverse discrete Fourier transform (DFT)</td>
924 <td valign="top">Label</td>
925 <td valign="top">string</td>
926 <td valign="top">assign a label to an image</td>
930 <td valign="top">Layers</td>
931 <td valign="top">method=>{coalesce, compare-any, compare-clear, compare-over, composite, dispose, flatten, merge, mosaic, optimize, optimize-image, optimize-plus, optimize-trans, remove-dups, remove-zero}, compose=>{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=>{true, false}</td>
932 <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>
936 <td valign="top">Level</td>
937 <td valign="top">levels=><i>string</i>, 'black-point'=><i>double</i>, 'gamma'=><i>double</i>, 'white-point'=><i>double</i>, channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
938 <td valign="top">adjust the level of image contrast</td>
942 <td valign="top">LevelColors</td>
943 <td valign="top">invert=>>{True, False}, 'black-point'=><i>string</i>, 'white-point'=><i>string</i>, channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
944 <td valign="top">level image with the given colors</td>
948 <td valign="top">LinearStretch</td>
949 <td valign="top">levels=><i>string</i>, 'black-point'=><i>double</i>, 'white-point'=><i>double</i></td>
950 <td valign="top">linear with saturation stretch</td>
954 <td valign="top">LiquidResize</td>
955 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, delta-x=><i>double</i>, rigidity=><i>double</i></td>
956 <td valign="top">rescale image with seam-carving.</td>
960 <td valign="top">Magnify</td>
961 <td valign="top"><br /></td>
962 <td valign="top">double the size of an image</td>
966 <td valign="top">Mask</td>
967 <td valign="top">mask=><i>image-handle</i></td>
968 <td valign="top">composite image pixels as defined by the mask</td>
972 <td valign="top">MatteFloodfill</td>
973 <td valign="top">geometry=><i>geometry</i>, x=><i>integer</i>, y=><i>integer</i> , matte=><i>integer</i>, bordercolor=><i><a href="../www/color.html">color name</a></i>, fuzz=><i>double</i>, invert=>{True, False}</td>
974 <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>
978 <td valign="top">MedianFilter</td>
979 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
980 <td valign="top">replace each pixel with the median intensity pixel of a neighborhood.</td>
984 <td valign="top">Minify</td>
985 <td valign="top"><br /></td>
986 <td valign="top">half the size of an image</td>
990 <td valign="top">Mode</td>
991 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
992 <td valign="top">make each pixel the <em>predominant color</em> of the neighborhood.</td>
996 <td valign="top">Modulate</td>
997 <td valign="top">factor=><i>geometry</i>, brightness=><i>double</i>, saturation=><i>double</i>, hue=><i>double</i>, lightness=><i>double</i>, whiteness=><i>double</i>, blackness=><i>double</i> </td>
998 <td valign="top">vary the brightness, saturation, and hue of an image by the specified percentage</td>
1002 <td valign="top">Morphology</td>
1003 <td valign="top">kernel=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, iterations=><i>integer</i></td>
1004 <td valign="top">apply a morphology method to the image.</td>
1008 <td valign="top">MotionBlur</td>
1009 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, angle=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1010 <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>
1014 <td valign="top">Negate</td>
1015 <td valign="top">gray=>{True, False}, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1016 <td valign="top">replace each pixel with its complementary color (white becomes black, yellow becomes blue, etc.)</td>
1020 <td valign="top">Normalize</td>
1021 <td valign="top">channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}<br /></td>
1022 <td valign="top">transform image to span the full range of color values</td>
1026 <td valign="top">OilPaint</td>
1027 <td valign="top">radius=><i>integer</i></td>
1028 <td valign="top">simulate an oil painting</td>
1032 <td valign="top">Opaque</td>
1033 <td valign="top">color=><i><a href="../www/color.html">color name</a></i>,
1034 fill=><i><a href="../www/color.html">color name</a></i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, invert=>{True, False}</td>
1035 <td valign="top">change this color to the fill color within the image</td>
1039 <td valign="top">OrderedDither</td>
1040 <td valign="top">threshold=>{threshold, checks, o2x2, o3x3, o4x4, o8x8, h4x4a, h6x6a, h8x8a, h4x4o, h6x6o, h8x8o, h16x16o, hlines6x4}, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1041 <td valign="top">order dither image</td>
1045 <td valign="top">Polaroid</td>
1046 <td valign="top">caption=><i>string</i>, angle=><i>double</i>, pointsize=><i>double</i>, font=><i>string</i>, stroke=> <i><a href="../www/color.html">color name</a></i>, strokewidth=><i>integer</i>, fill=><i><a href="../www/color.html">color name</a></i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, background=><i><a href="../www/color.html">color name</a></i></td>
1047 <td valign="top">simulate a Polaroid picture.</td>
1051 <td valign="top">Posterize</td>
1052 <td valign="top">levels=><i>integer</i>, dither=>{True, False}</td>
1053 <td valign="top">reduce the image to a limited number of color level</td>
1057 <td valign="top">Profile</td>
1058 <td valign="top">name=><i>string</i>, profile=><i>blob</i>, rendering-intent=>{Undefined, Saturation, Perceptual, Absolute, Relative}, black-point-compensation=>{True, False}</td>
1059 <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>
1063 <td valign="top">Quantize</td>
1064 <td valign="top">colors=><i>integer</i>, colorspace=>{RGB, Gray, Transparent, OHTA, XYZ, YCbCr, YIQ, YPbPr, YUV, CMYK, sRGB, HSL, HSB}, treedepth=> <i>integer</i>, dither=>{True, False}, dither-method=>{Riemersma, Floyd-Steinberg}, measure_error=>{True, False}, global_colormap=>{True, False}, transparent-color=><i>color</i></td>
1065 <td valign="top">preferred number of colors in the image</td>
1069 <td valign="top">RadialBlur</td>
1070 <td valign="top">geometry=><i>geometry</i>, angle=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1071 <td valign="top">radial blur the image.</td>
1075 <td valign="top">Raise</td>
1076 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, raise=>{True, False}</td>
1077 <td valign="top">lighten or darken image edges to create a 3-D effect</td>
1081 <td valign="top">ReduceNoise</td>
1082 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1083 <td valign="top">reduce noise in the image with a noise peak elimination filter</td>
1087 <td valign="top">Remap</td>
1088 <td valign="top">image=><i>image-handle</i>, dither=>{true, false}, dither-method=>{Riemersma, Floyd-Steinberg}</td>
1089 <td valign="top">replace the colors of an image with the closest color from a reference image.</td>
1093 <td valign="top">Resample</td>
1094 <td valign="top">density=><i>geometry</i>, x=><i>double</i>, y=><i>double</i>, filter=>{Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, Sinc}, support=><i>double</i></td>
1095 <td valign="top">resample image to desired resolution. Specify <kbd>blur</kbd> > 1 for blurry or < 1 for sharp</td>
1099 <td valign="top">Resize</td>
1100 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, filter=>{Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, Sinc}, support=><i>double</i>, blur=><i>double</i></td>
1101 <td valign="top">scale image to desired size. Specify <kbd>blur</kbd> > 1 for blurry or < 1 for sharp</td>
1105 <td valign="top">Roll</td>
1106 <td valign="top">geometry=><i>geometry</i>, x=><i>integer</i>, y=><i>integer</i></td>
1107 <td valign="top">roll an image vertically or horizontally</td>
1111 <td valign="top">Rotate</td>
1112 <td valign="top">degrees=><i>double</i>, background=><i><a href="../www/color.html">color name</a></i></td>
1113 <td valign="top">rotate an image</td>
1117 <td valign="top">Sample</td>
1118 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td>
1119 <td valign="top">scale image with pixel sampling.</td>
1123 <td valign="top">Scale</td>
1124 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td>
1125 <td valign="top">scale image to desired size</td>
1129 <td valign="top">Segment</td>
1130 <td valign="top">colorspace=>{RGB, Gray, Transparent, OHTA, XYZ, YCbCr, YCC, YIQ, YPbPr, YUV, CMYK}, verbose={True, False}, cluster-threshold=><i>double</i>, smoothing-threshold=<i>double</i></td>
1131 <td valign="top">segment an image by analyzing the histograms of the color components and identifying units that are homogeneous</td>
1135 <td valign="top">SelectiveBlur</td>
1136 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, threshold=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1137 <td valign="top">selectively blur pixels within a contrast threshold.</td>
1140 <td valign="top">Separate</td>
1141 <td valign="top">channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td>
1142 <td valign="top">separate a channel from the image into a grayscale image</td>
1146 <td valign="top">Shade</td>
1147 <td valign="top">geometry=><i>geometry</i>, azimuth=><i>double</i>, elevation=><i>double</i>, gray=>{true, false}</td>
1148 <td valign="top">shade the image using a distant light source</td>
1152 <td valign="top">SetPixel</td>
1153 <td valign="top">geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, color=><i>array of float values</i>, x=><i>integer</i>, y=><i>integer</i>, color=><i>array of float values</i></td>
1154 <td valign="top">set a single pixel. By default normalized pixel values are expected.</td>
1158 <td valign="top">Shadow</td>
1159 <td valign="top">geometry=><i>geometry</i>, opacity=><i>double</i>, sigma=><i>double</i>, x=><i>integer</i>, y=><i>integer</i></td>
1160 <td valign="top">simulate an image shadow</td>
1164 <td valign="top">Sharpen</td>
1165 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1166 <td valign="top">sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma).</td>
1170 <td valign="top">Shave</td>
1171 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td>
1172 <td valign="top">shave pixels from the image edges</td>
1176 <td valign="top">Shear</td>
1177 <td valign="top">geometry=><i>geometry</i>, x=><i>double</i>, y=><i>double</i> fill=><i><a href="../www/color.html">color name</a></i></td>
1178 <td valign="top">shear the image along the X or Y axis by a positive or negative shear angle</td>
1182 <td valign="top">SigmoidalContrast</td>
1183 <td valign="top">geometry=><i>string</i>, 'contrast'=><i>double</i>, 'mid-point'=><i>double</i> channel=>{Red, RGB, CMYK, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}, sharpen=>{True, False}</td>
1184 <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>
1188 <td valign="top">Signature</td>
1189 <td valign="top"><br /></td>
1190 <td valign="top">generate an SHA-256 message digest for the image pixel stream</td>
1194 <td valign="top">Sketch</td>
1195 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, angle=><i>double</i></td>
1196 <td valign="top">sketch the image with a Gaussian operator of the given radius and standard deviation (sigma) at the given angle</td>
1200 <td valign="top">Solarize</td>
1201 <td valign="top">geometry=><i>string</i>,threshold=><i>double</i></td>
1202 <td valign="top">negate all pixels above the threshold level</td>
1206 <td valign="top">SparseColor</td>
1207 <td valign="top">points=><i>array of float values</i>, method=>{Barycentric, Bilinear, Shepards, Voronoi}, virtual-pixel=>{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
1208 <td valign="top">interpolate the image colors around the supplied points</td>
1212 <td valign="top">Splice</td>
1213 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, fuzz=><i>double</i>, background=><i><a href="../www/color.html">color name</a></i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
1214 <td valign="top">splice an image</td>
1218 <td valign="top">Spread</td>
1219 <td valign="top">radius=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
1220 <td valign="top">displace image pixels by a random amount</td>
1224 <td valign="top">Statistic</td>
1225 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, type=>{Median, Mode, Mean, Maximum, Minimum, ReduceNoise}</td>
1226 <td valign="top">replace each pixel with corresponding statistic from the neighborhood.</td>
1229 <td valign="top">Stegano</td>
1230 <td valign="top">image=><i>image-handle</i>, offset=><i>integer</i></td>
1231 <td valign="top">hide a digital watermark within the image</td>
1235 <td valign="top">Stereo</td>
1236 <td valign="top">image=><i>image-handle</i>, x=><i>integer</i>, y=><i>integer</i></td>
1237 <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>
1241 <td valign="top">Strip</td>
1242 <td valign="top"><br /></td>
1243 <td valign="top">strip an image of all profiles and comments.</td>
1247 <td valign="top">Swirl</td>
1248 <td valign="top">degrees=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
1249 <td valign="top">swirl image pixels about the center</td>
1253 <td valign="top">Texture</td>
1254 <td valign="top">texture=><i>image-handle</i></td>
1255 <td valign="top">name of texture to tile onto the image background</td>
1259 <td valign="top">Thumbnail</td>
1260 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td>
1261 <td valign="top">changes the size of an image to the given dimensions and removes any associated profiles.</td>
1265 <td valign="top">Threshold</td>
1266 <td valign="top">threshold=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1267 <td valign="top">threshold the image</td>
1271 <td valign="top">Tint</td>
1272 <td valign="top">fill=><i><a href="../www/color.html">color name</a></i>, blend=><i>string</i></td>
1273 <td valign="top">tint the image with the fill color.</td>
1277 <td valign="top">Transparent</td>
1278 <td valign="top">color=><i><a href="../www/color.html">color name</a></i>, invert=>{True, False}</td>
1279 <td valign="top">make this color transparent within the image</td>
1283 <td valign="top">Transpose</td>
1284 <td valign="top"><br /></td>
1285 <td valign="top">flip image in the vertical direction and rotate 90 degrees</td>
1289 <td valign="top">Transverse</td>
1290 <td valign="top"><br /></td>
1291 <td valign="top">flop image in the horizontal direction and rotate 270 degrees</td>
1295 <td valign="top">Trim</td>
1296 <td valign="top"><br /></td>
1297 <td valign="top">remove edges that are the background color from the image</td>
1301 <td valign="top">UnsharpMask</td>
1302 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, amount=><i>double</i>, threshold=><i>double</i></td>
1303 <td valign="top">sharpen the image with the unsharp mask algorithm.</td>
1307 <td valign="top">Vignette</td>
1308 <td valign="top">geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, x=><i>integer</i>, y=><i>integer</i>, background=><i><a href="../www/color.html">color name</a></i></td>
1309 <td valign="top">offset the edges of the image in vignette style</td>
1313 <td valign="top">Wave</td>
1314 <td valign="top">geometry=><i>geometry</i>, amplitude=><i>double</i>, wavelength=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td>
1315 <td valign="top">alter an image along a sine wave</td>
1319 <td valign="top">WhiteThreshold</td>
1320 <td valign="top">threshold=><i>string</i>, , channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}</td>
1321 <td valign="top">force all pixels above the threshold intensity into white</td>
1326 <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=>'106x80'</kbd> is equivalent to <kbd>width=>106, height=>80</kbd> ).</p>
1328 <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>
1331 $image->Draw(fill=>'red', primitive=>'rectangle',
1332 points=>'20,20 100,100 40,40 200,200 60,60 300,300');
1335 <p>Is equivalent to</p>
1338 $image->Draw(fill=>'red', primitive=>'@draw.txt');
1341 <p>Where <kbd>draw.txt</kbd> is a file on disk that contains this:</p>
1344 rectangle 20, 20 100, 100
1345 rectangle 40, 40 200, 200
1346 rectangle 60, 60 300, 300
1349 <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>
1355 %e filename extension
1360 %k number of unique colors
1367 %r image class and colorspace
1370 %u unique temporary filename
1375 %C image compression type
1376 %D image dispose method
1378 %Q image compression quality
1393 text=>"%m:%f %wx%h"
1396 <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>
1398 <p>You can optionally add <i>Image</i> to any method name. For example, TrimImage() is an alias for method Trim().</p>
1400 <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>
1404 <h2><a id="set-attribute"></a>Set an Image Attribute</h2>
1405 <div class="doc-section">
1407 <p>Use method Set() to set an image attribute. For example,</p>
1410 $image->Set(dither=>'True');
1411 $image->[$x]->Set(delay=>3);
1414 <p>Where this example uses 'True' and this document says '{True, False}',
1415 you can use the case-insensitive strings 'True' and 'False', or you
1416 can use the integers 1 and 0.</p>
1418 <p>When you call Get() on a Boolean attribute, Image::Magick returns 1 or 0, not a string.</p>
1420 <p>And here is a list of all the image attributes you can set:</p>
1423 <caption>Image Attributes</caption>
1427 <th style="width: 40%">Values</th>
1428 <th style="width: 40%">Description</th>
1432 <td valign="top">adjoin</td>
1433 <td valign="top">{True, False}</td>
1434 <td valign="top">join images into a single multi-image file</td>
1438 <td valign="top">alpha</td>
1439 <td valign="top">{On, Off, Opaque, Transparent, Copy, Extract, Set}</td>
1440 <td valign="top">control of and special operations involving the alpha/matte channel</td>
1444 <td valign="top">antialias</td>
1445 <td valign="top">{True, False}</td>
1446 <td valign="top">remove pixel aliasing</td>
1450 <td valign="top">area-limit</td>
1451 <td valign="top"><i>integer</i></td>
1452 <td valign="top">set pixel area resource limit.</td>
1456 <td valign="top">attenuate</td>
1457 <td valign="top"><i>double</i></td>
1458 <td valign="top">lessen (or intensify) when adding noise to an image.</td>
1462 <td valign="top">authenticate</td>
1463 <td valign="top"><i>string</i></td>
1464 <td valign="top">decrypt image with this password.</td>
1468 <td valign="top">background</td>
1469 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1470 <td valign="top">image background color</td>
1474 <td valign="top">blue-primary</td>
1475 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1476 <td valign="top">chromaticity blue primary point (e.g. 0.15, 0.06)</td>
1480 <td valign="top">bordercolor</td>
1481 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1482 <td valign="top">set the image border color</td>
1486 <td valign="top">clip-mask</td>
1487 <td valign="top"><i>image</i></td>
1488 <td valign="top">associate a clip mask with the image.</td>
1492 <td valign="top">colormap[<i>i</i>]</td>
1493 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1494 <td valign="top">color name (e.g. red) or hex value (e.g. #ccc) at position
1499 <td valign="top">comment</td>
1500 <td valign="top"><i>string</i></td>
1501 <td valign="top">set the image comment</td>
1505 <td valign="top">compression</td>
1506 <td valign="top">{None, BZip, Fax, Group4, JPEG, JPEG2000, LosslessJPEG, LZW, RLE, Zip}</td>
1507 <td valign="top">type of image compression</td>
1511 <td valign="top">debug</td>
1512 <td valign="top">{All, Annotate, Blob, Cache, Coder, Configure, Deprecate, Draw, Exception, Locale, None, Resource, Transform, X11}</td>
1513 <td valign="top">display copious debugging information</td>
1517 <td valign="top">delay</td>
1518 <td valign="top"><i>integer</i></td>
1519 <td valign="top">this many 1/100ths of a second must expire before displaying the next image in a sequence</td>
1523 <td valign="top">density</td>
1524 <td valign="top"><i>geometry</i></td>
1525 <td valign="top">vertical and horizontal resolution in pixels of the image</td>
1529 <td valign="top">depth</td>
1530 <td valign="top"><i>integer</i></td>
1531 <td valign="top">image depth</td>
1535 <td valign="top">direction</td>
1536 <td valign="top"><i>{Undefined, right-to-left, left-to-right</i></td>
1537 <td valign="top">render text right-to-left or left-to-right</td>
1541 <td valign="top">disk-limit</td>
1542 <td valign="top"><i>integer</i></td>
1543 <td valign="top">set disk resource limit</td>
1547 <td valign="top">dispose</td>
1548 <td valign="top"><i>{Undefined, None, Background, Previous}</i></td>
1549 <td valign="top">layer disposal method</td>
1553 <td valign="top">dither</td>
1554 <td valign="top">{True, False}</td>
1555 <td valign="top">apply error diffusion to the image</td>
1559 <td valign="top">display</td>
1560 <td valign="top"><i>string</i></td>
1561 <td valign="top">specifies the X server to contact</td>
1565 <td valign="top">extract</td>
1566 <td valign="top"><i>geometry</i></td>
1567 <td valign="top">extract area from image</td>
1571 <td valign="top">file</td>
1572 <td valign="top"><i>filehandle</i></td>
1573 <td valign="top">set the image filehandle</td>
1577 <td valign="top">filename</td>
1578 <td valign="top"><i>string</i></td>
1579 <td valign="top">set the image filename</td>
1583 <td valign="top">fill</td>
1584 <td valign="top"><i>color</i></td>
1585 <td valign="top">The fill color paints any areas inside the outline of drawn shape.</td>
1589 <td valign="top">font</td>
1590 <td valign="top"><i>string</i></td>
1591 <td valign="top">use this font when annotating the image with text</td>
1595 <td valign="top">fuzz</td>
1596 <td valign="top"><i>integer</i></td>
1597 <td valign="top">colors within this distance are considered equal</td>
1601 <td valign="top">gamma</td>
1602 <td valign="top"><i>double</i></td>
1603 <td valign="top">gamma level of the image</td>
1607 <td valign="top">Gravity</td>
1608 <td valign="top">{Forget, NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td>
1609 <td valign="top">type of image gravity</td>
1613 <td valign="top">green-primary</td>
1614 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1615 <td valign="top">chromaticity green primary point (e.g. 0.3, 0.6)</td>
1619 <td valign="top">index[<i>x</i>, <i>y</i>]</td>
1620 <td valign="top"><i>string</i></td>
1621 <td valign="top">colormap index at position (<i>x</i>, <i>y</i>)</td>
1625 <td valign="top">interlace</td>
1626 <td valign="top">{None, Line, Plane, Partition, JPEG, GIF, PNG}</td>
1627 <td valign="top">the type of interlacing scheme</td>
1631 <td valign="top">iterations</td>
1632 <td valign="top"><i>integer</i></td>
1633 <td valign="top">add Netscape loop extension to your GIF animation</td>
1637 <td valign="top">label</td>
1638 <td valign="top"><i>string</i></td>
1639 <td valign="top">set the image label</td>
1643 <td valign="top">loop</td>
1644 <td valign="top"><i>integer</i></td>
1645 <td valign="top">add Netscape loop extension to your GIF animation</td>
1649 <td valign="top">magick</td>
1650 <td valign="top"><i>string</i></td>
1651 <td valign="top">set the image format</td>
1655 <td valign="top">map-limit</td>
1656 <td valign="top"><i>integer</i></td>
1657 <td valign="top">set map resource limit</td>
1661 <td valign="top">mask</td>
1662 <td valign="top"><i>image</i></td>
1663 <td valign="top">associate a mask with the image.</td>
1667 <td valign="top">matte</td>
1668 <td valign="top">{True, False}</td>
1669 <td valign="top">enable the image matte channel</td>
1673 <td valign="top">mattecolor</td>
1674 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
1675 <td valign="top">set the image matte color</td>
1679 <td valign="top">memory-limit</td>
1680 <td valign="top"><i>integer</i></td>
1681 <td valign="top">set memory resource limit</td>
1685 <td valign="top">monochrome</td>
1686 <td valign="top">{True, False}</td>
1687 <td valign="top">transform the image to black and white</td>
1691 <td valign="top">option</td>
1692 <td valign="top"><i>string</i></td>
1693 <td valign="top">associate an option with an image format (e.g. option=>'ps:imagemask'</td>
1697 <td valign="top">orientation</td>
1698 <td valign="top">{top-left, top-right, bottom-right, bottom-left, left-top, right-top, right-bottom, left-bottom}</td>
1699 <td valign="top">image orientation</td>
1703 <td valign="top">page</td>
1704 <td valign="top">{ Letter, Tabloid, Ledger, Legal, Statement, Executive, A3, A4, A5, B4, B5, Folio, Quarto, 10x14} or <i>geometry</i></td>
1705 <td valign="top">preferred size and location of an image canvas</td>
1709 <td valign="top">pixel[<i>x</i>, <i>y</i>]</td>
1710 <td valign="top"><i>string</i></td>
1711 <td valign="top">hex value (e.g. #ccc) at position (<i>x</i>, <i>y</i>)</td>
1715 <td valign="top">pointsize</td>
1716 <td valign="top"><i>integer</i></td>
1717 <td valign="top">pointsize of the Postscript or TrueType font</td>
1721 <td valign="top">quality</td>
1722 <td valign="top"><i>integer</i></td>
1723 <td valign="top">JPEG/MIFF/PNG compression level</td>
1727 <td valign="top">red-primary</td>
1728 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1729 <td valign="top">chromaticity red primary point (e.g. 0.64, 0.33)</td>
1733 <td valign="top">sampling-factor</td>
1734 <td valign="top"><i>geometry</i></td>
1735 <td valign="top">horizontal and vertical sampling factor</td>
1739 <td valign="top">scene</td>
1740 <td valign="top"><i>integer</i></td>
1741 <td valign="top">image scene number</td>
1745 <td valign="top">server</td>
1746 <td valign="top"><i>string</i></td>
1747 <td valign="top">specifies the X server to contact</td>
1751 <td valign="top">size</td>
1752 <td valign="top"><i>string</i></td>
1753 <td valign="top">width and height of a raw image</td>
1757 <td valign="top">stroke</td>
1758 <td valign="top"><i>color</i></td>
1759 <td valign="top">The stroke color paints along the outline of a shape.</td>
1763 <td valign="top">texture</td>
1764 <td valign="top"><i>string</i></td>
1765 <td valign="top">name of texture to tile onto the image background</td>
1769 <td valign="top">tile-offset</td>
1770 <td valign="top"><i>geometry</i></td>
1771 <td valign="top">image tile offset</td>
1775 <td valign="top">time-limit</td>
1776 <td valign="top"><i>integer</i></td>
1777 <td valign="top">set time resource limit in seconds</td>
1781 <td valign="top">type</td>
1782 <td valign="top">{Bilevel, Grayscale, GrayscaleMatte, Palette, PaletteMatte, TrueColor, TrueColorMatte, ColorSeparation, ColorSeparationMatte}</td>
1783 <td valign="top">image type</td>
1787 <td valign="top">units</td>
1788 <td valign="top">{ Undefined, PixelsPerInch, PixelsPerCentimeter}</td>
1789 <td valign="top">units of image resolution</td>
1793 <td valign="top">verbose</td>
1794 <td valign="top">{True, False}</td>
1795 <td valign="top">print detailed information about the image</td>
1799 <td valign="top">virtual-pixel</td>
1800 <td valign="top">{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td>
1801 <td valign="top">the virtual pixel method</td>
1805 <td valign="top">white-point</td>
1806 <td valign="top"><i>x-value</i>, <i>y-value</i></td>
1807 <td valign="top">chromaticity white point (e.g. 0.3127, 0.329)</td>
1812 <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=>'106x80'</kbd> is equivalent to <kbd>width=>106, height=>80</kbd>).</p>
1814 <p>SetAttribute() is an alias for method Set().</p>
1816 <p>Most of the attributes listed above have an analog in
1817 <a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
1821 <h2><a id="get-attribute"></a>Get an Image Attribute</h2>
1822 <div class="doc-section">
1824 <p>Use method Get() to get an image attribute. For example,</p>
1827 ($a, $b, $c) = $image->Get('colorspace', 'magick', 'adjoin');
1828 $width = $image->[3]->Get('columns');
1831 <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>
1834 <caption>Image Attributes</caption>
1839 <th style="width: 60%">Description</th>
1843 <td valign="top">area</td>
1844 <td valign="top"><i>integer</i></td>
1845 <td valign="top">current area resource consumed</td>
1849 <td valign="top">base-columns</td>
1850 <td valign="top"><i>integer</i></td>
1851 <td valign="top">base image width (before transformations)</td>
1855 <td valign="top">base-filename</td>
1856 <td valign="top"><i>string</i></td>
1857 <td valign="top">base image filename (before transformations)</td>
1861 <td valign="top">base-rows</td>
1862 <td valign="top"><i>integer</i></td>
1863 <td valign="top">base image height (before transformations)</td>
1867 <td valign="top">class</td>
1868 <td valign="top">{Direct, Pseudo}</td>
1869 <td valign="top">image class</td>
1873 <td valign="top">colors</td>
1874 <td valign="top"><i>integer</i></td>
1875 <td valign="top">number of unique colors in the image</td>
1879 <td valign="top">columns</td>
1880 <td valign="top"><i>integer</i></td>
1881 <td valign="top">image width</td>
1885 <td valign="top">copyright</td>
1886 <td valign="top"><i>string</i></td>
1887 <td valign="top">get PerlMagick's copyright</td>
1891 <td valign="top">directory</td>
1892 <td valign="top"><i>string</i></td>
1893 <td valign="top">tile names from within an image montage</td>
1897 <td valign="top">elapsed-time</td>
1898 <td valign="top"><i>double</i></td>
1899 <td valign="top">elapsed time in seconds since the image was created</td>
1903 <td valign="top">error</td>
1904 <td valign="top"><i>double</i></td>
1905 <td valign="top">the mean error per pixel computed with methods Compare() or Quantize()</td>
1909 <td valign="top">bounding-box</td>
1910 <td valign="top"><i>string</i></td>
1911 <td valign="top">image bounding box</td>
1915 <td valign="top">disk</td>
1916 <td valign="top"><i>integer</i></td>
1917 <td valign="top">current disk resource consumed</td>
1921 <td valign="top">filesize</td>
1922 <td valign="top"><i>integer</i></td>
1923 <td valign="top">number of bytes of the image on disk</td>
1927 <td valign="top">format</td>
1928 <td valign="top"><i>string</i></td>
1929 <td valign="top">get the descriptive image format</td>
1933 <td valign="top">geometry</td>
1934 <td valign="top"><i>string</i></td>
1935 <td valign="top">image geometry</td>
1939 <td valign="top">height</td>
1940 <td valign="top"><i>integer</i></td>
1941 <td valign="top">the number of rows or height of an image</td>
1945 <td valign="top">id</td>
1946 <td valign="top"><i>integer</i></td>
1947 <td valign="top">ImageMagick registry id</td>
1951 <td valign="top">mean-error</td>
1952 <td valign="top"><i>double</i></td>
1953 <td valign="top">the normalized mean error per pixel computed with methods Compare() or Quantize()</td>
1957 <td valign="top">map</td>
1958 <td valign="top"><i>integer</i></td>
1959 <td valign="top">current memory-mapped resource consumed</td>
1963 <td valign="top">matte</td>
1964 <td valign="top">{True, False}</td>
1965 <td valign="top">whether or not the image has a matte channel</td>
1969 <td valign="top">maximum-error</td>
1970 <td valign="top"><i>double</i></td>
1971 <td valign="top">the normalized max error per pixel computed with methods Compare() or Quantize()</td>
1975 <td valign="top">memory</td>
1976 <td valign="top"><i>integer</i></td>
1977 <td valign="top">current memory resource consumed</td>
1981 <td valign="top">mime</td>
1982 <td valign="top"><i>string</i></td>
1983 <td valign="top">MIME of the image format</td>
1987 <td valign="top">montage</td>
1988 <td valign="top"><i>geometry</i></td>
1989 <td valign="top">tile size and offset within an image montage</td>
1993 <td valign="top">page.x</td>
1994 <td valign="top"><i>integer</i></td>
1995 <td valign="top">x offset of image virtual canvas</td>
1999 <td valign="top">page.y</td>
2000 <td valign="top"><i>integer</i></td>
2001 <td valign="top">y offset of image virtual canvas</td>
2005 <td valign="top">rows</td>
2006 <td valign="top"><i>integer</i></td>
2007 <td valign="top">the number of rows or height of an image</td>
2011 <td valign="top">signature</td>
2012 <td valign="top"><i>string</i></td>
2013 <td valign="top">SHA-256 message digest associated with the image pixel stream</td>
2017 <td valign="top">taint</td>
2018 <td valign="top">{True, False}</td>
2019 <td valign="top">True if the image has been modified</td>
2023 <td valign="top">total-ink-density</td>
2024 <td valign="top"><i>double</i></td>
2025 <td valign="top">returns the total ink density for a CMYK image</td>
2029 <td valign="top">transparent-color</td>
2030 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
2031 <td valign="top">set the image transparent color</td>
2035 <td valign="top">user-time</td>
2036 <td valign="top"><i>double</i></td>
2037 <td valign="top">user time in seconds since the image was created</td>
2041 <td valign="top">version</td>
2042 <td valign="top"><i>string</i></td>
2043 <td valign="top">get PerlMagick's version</td>
2047 <td valign="top">width</td>
2048 <td valign="top"><i>integer</i></td>
2049 <td valign="top">the number of columns or width of an image</td>
2053 <td valign="top">x-resolution</td>
2054 <td valign="top"><i>integer</i></td>
2055 <td valign="top">x resolution of the image</td>
2059 <td valign="top">y-resolution</td>
2060 <td valign="top"><i>integer</i></td>
2061 <td valign="top">y resolution of the image</td>
2066 <p>GetAttribute() is an alias for method Get().</p>
2068 <p>Most of the attributes listed above have an analog in
2069 <a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p>
2073 <h2><a id="compare"></a>Compare an Image to its Reconstruction</h2>
2074 <div class="doc-section">
2077 <p>Mathematically and visually annotate the difference between an image and its reconstruction with the Compare() method. The method supports these parameters:</p>
2080 <caption>Compare Parameters</caption>
2084 <th style="width: 40%">Values</th>
2085 <th style="width: 40%">Description</th>
2089 <td valign="top">channel</td>
2090 <td valign="top"><i>double</i></td>
2091 <td valign="top">select image channels, the default is all channels except alpha.</td>
2095 <td valign="top">fuzz</td>
2096 <td valign="top"><i>double</i></td>
2097 <td valign="top">colors within this distance are considered equal</td>
2101 <td valign="top">image</td>
2102 <td valign="top"><i>image-reference</i></td>
2103 <td valign="top">the image reconstruction</td>
2107 <td valign="top">metric</td>
2108 <td valign="top">AE, MAE, MEPP, MSE, PAE, PSNR, RMSE</td>
2109 <td valign="top">measure differences between images with this metric</td>
2114 <p>In this example, we compare the ImageMagick logo to a sharpened reconstruction:</p>
2119 $logo=Image::Magick->New();
2120 $logo->Read('logo:');
2121 $sharp=Image::Magick->New();
2122 $sharp->Read('logo:');
2123 $sharp->Sharpen('0x1');
2124 $difference=$logo->Compare(image=>$sharp, metric=>'rmse');
2125 print $difference->Get('error'), "\n";
2126 $difference->Display();
2129 <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>
2131 <h2><a id="montage"></a>Create an Image Montage</h2>
2132 <div class="doc-section">
2134 <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>
2137 $image->Montage(geometry=>'160x160', tile=>'2x2', texture=>'granite:');
2140 <p>And here is a list of Montage() parameters you can set:</p>
2143 <caption>Montage Parameters</caption>
2147 <th style="width: 40%">Values</th>
2148 <th style="width: 40%">Description</th>
2152 <td valign="top">background</td>
2153 <td valign="top"><i><a href="../www/color.html">color name</a></i></td>
2154 <td valign="top">background color name</td>
2158 <td valign="top">border</td>
2159 <td valign="top"><i>integer</i></td>
2160 <td valign="top">image border width</td>
2164 <td valign="top">filename</td>
2165 <td valign="top"><i>string</i></td>
2166 <td valign="top">name of montage image</td>
2170 <td valign="top">fill</td>
2171 <td valign="top"><a href="../www/color.html">color name</a></td>
2172 <td valign="top">fill color for annotations</td>
2176 <td valign="top">font</td>
2177 <td valign="top"><i>string</i></td>
2178 <td valign="top">X11 font name</td>
2182 <td valign="top">frame</td>
2183 <td valign="top"><i>geometry</i></td>
2184 <td valign="top">surround the image with an ornamental border</td>
2188 <td valign="top">geometry</td>
2189 <td valign="top"><i>geometry</i></td>
2190 <td valign="top">preferred tile and border size of each tile of the composite
2191 image (e.g. 120x120+4+3>)</td>
2195 <td valign="top">gravity</td>
2196 <td valign="top">NorthWest, North, NorthEast, West, Center, East, SouthWest,
2197 South, SouthEast</td>
2198 <td valign="top">direction image gravitates to within a tile</td>
2202 <td valign="top">label</td>
2203 <td valign="top"><i>string</i></td>
2204 <td valign="top">assign a label to an image</td>
2208 <td valign="top">mode</td>
2209 <td valign="top">Frame, Unframe, Concatenate</td>
2210 <td valign="top">thumbnail framing options</td>
2214 <td valign="top">pointsize</td>
2215 <td valign="top"><i>integer</i></td>
2216 <td valign="top">pointsize of the Postscript or TrueType font</td>
2220 <td valign="top">shadow</td>
2221 <td valign="top">{True, False}</td>
2222 <td valign="top">add a shadow beneath a tile to simulate depth</td>
2226 <td valign="top">stroke</td>
2227 <td valign="top"><a href="../www/color.html">color name</a></td>
2228 <td valign="top">stroke color for annotations</td>
2232 <td valign="top">texture</td>
2233 <td valign="top"><i>string</i></td>
2234 <td valign="top">name of texture to tile onto the image background</td>
2238 <td valign="top">tile</td>
2239 <td valign="top"><i>geometry</i></td>
2240 <td valign="top">the number of tiles per row and page (e.g. 6x4)</td>
2244 <td valign="top">title</td>
2245 <td valign="top">string</td>
2246 <td valign="top">assign a title to the image montage</td>
2250 <td valign="top">transparent</td>
2251 <td valign="top"><i>string</i></td>
2252 <td valign="top">make this color transparent within the image</td>
2257 <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=>'106x80'</kbd> is equivalent to <kbd>width=>106, height=>80</kbd>).</p>
2259 <p>MontageImage() is an alias for method Montage().</p>
2261 <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>
2265 <h2><a id="blobs"></a>Working with Blobs</h2>
2266 <div class="doc-section">
2268 <p>A blob contains data that directly represent a particular image
2269 format in memory instead of on disk. PerlMagick supports
2270 blobs 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>
2273 <caption>Blob Methods</caption>
2278 <th>Return Value</th>
2279 <th>Description</th>
2283 <td valign="top">ImageToBlob</td>
2284 <td valign="top">any image <a href="#set-attribute">attribute</a></td>
2285 <td valign="top">an array of image data in the respective image format</td>
2286 <td valign="top">convert an image or image sequence to an array of blobs</td>
2290 <td valign="top">BlobToImage</td>
2291 <td valign="top">one or more blobs</td>
2292 <td valign="top">the number of blobs converted to an image</td>
2293 <td valign="top">convert one or more blobs to an image</td>
2298 <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>
2301 @blobs = $image->ImageToBlob();
2302 open(DISPLAY,"| display -") || die;
2304 print DISPLAY $blobs[0];
2308 <p>Method BlobToImage() returns an image or image sequence converted from the supplied blob:</p>
2311 @blob=$db->GetImage();
2312 $image=Image::Magick->new(magick=>'jpg');
2313 $image->BlobToImage(@blob);
2318 <h2><a id="direct-access"></a>Direct-access to Image Pixels</h2>
2319 <div class="doc-section">
2321 <p>Use these methods to obtain direct access to the image pixels:</p>
2324 <caption>Direct-access to Image Pixels</caption>
2329 <th style="width: 50%">Description</th>
2333 <td valign="top">GetAuthenticPixels</td>
2334 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i></td>
2335 <td valign="top">return image pixels as a C pointer</td>
2339 <td valign="top">GetVirtualPixels</td>
2340 <td valign="top">geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i></td>
2341 <td valign="top">return image pixels as a const C pointer</td>
2345 <td valign="top">GetAuthenticIndexQueue</td>
2346 <td valign="top"></td>
2347 <td valign="top">return image indexes as a C pointer</td>
2351 <td valign="top">GetVirtualIndexQueue</td>
2352 <td valign="top"></td>
2353 <td valign="top">return image indexes as a const C pointer</td>
2357 <td valign="top">SyncAuthenticPixels</td>
2358 <td valign="top"></td>
2359 <td valign="top">sync image pixels to pixel cache</td>
2367 <h2><a id="miscellaneous"></a>Miscellaneous Methods</h2>
2368 <div class="doc-section">
2370 <p>The Append() method append a set of images. For example,</p>
2373 $p = $image->Append(stack=>{true,false});
2376 <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>
2378 <p>The Clone() method copies a set of images. For example,</p>
2381 $q = $p->Clone();
2384 <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>
2386 <p>The EvaluateImages() method applies an arithemtic, logical or relational expression to a set of images. For example,</p>
2389 $p = $image->EvaluateImages('mean');
2392 <p>averages all the images associated with object <kbd>$image</kbd>.</p>
2394 <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>
2397 @features = $image->Features(1);
2400 <p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p>
2402 <p>The Flatten() method flattens a set of images and returns it. For example,</p>
2405 $p = $images->Flatten(background=>'none');
2406 $p->Write('flatten.png');
2409 <p>The sequence of images is replaced by a single image created by composing each image after the first over the first image.</p>
2411 <p>The Fx() method applies a mathematical expression to a set of images and returns the results. For example,</p>
2414 $p = $image->Fx(expression=>'(g+b)/2.0',channel=>'red');
2415 $p->Write('fx.miff');
2418 <p>replaces the red channel with the average of the green and blue channels.</p>
2420 <p>See <a href="../www/fx.html">FX, The Special Effects Image Operator</a> for a detailed discussion of this method.</p>
2422 <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>
2424 <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>
2427 $p = $image->Morph(frames=><i>integer</i>);
2430 <p>where <i>frames</i> is the number of in-between images to generate. The default is 1.</p>
2432 <p>Mosaic() creates an mosaic from an image sequence.</p>
2434 <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>
2437 $image->Crop('340x256+0+0');
2438 $image->Mogrify('crop', '340x256+0+0');
2441 <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>
2444 $image->MogrifyRegion('100x100+40+50', 'modulate', brightness=>50);
2447 <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>
2450 ($width, $height, $size, $format) = $image->Ping('logo.png');
2451 ($width, $height, $size, $format) = $image->Ping(file=>\*IMAGE);
2452 ($width, $height, $size, $format) = $image->Ping(blob=>$blob);
2455 <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>
2458 $preview = $image->Preview('Gamma');
2459 $preview->Display();
2462 <p>To have full control over text positioning you need font metric information. Use</p>
2465 ($x_ppem, $y_ppem, $ascender, $descender, $width, $height, $max_advance)
2466 = $image->QueryFontMetrics(<i>parameters</i>);
2469 <p>Where <i>parameters</i> is any parameter of the <a href="#manipulate">Annotate</a> method. The return values are:</p>
2472 <li>character width</li>
2473 <li>character height</li>
2477 <li>text height</li>
2478 <li>maximum horizontal advance</li>
2487 <p>Use QueryMultilineFontMetrics() to get the maximum text width and height for multiple lines of text.</p>
2489 <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>
2492 @colors = $image->QueryColor();
2493 ($red, $green, $blue, $opacity) = $image->QueryColor('cyan');
2494 ($red, $green, $blue, $opacity) = $image->QueryColor('#716bae');
2497 <p>QueryColorname() accepts a color value and returns its respective name or hex value;</p>
2500 $name = $image->QueryColorname('rgba(80,60,0,0)');
2503 <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>
2506 @fonts = $image->QueryFont();
2507 $weight = ($image->QueryFont('Helvetica'))[5];
2510 <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>
2513 @formats = $image->QueryFormat();
2514 ($adjoin, $blob_support, $raw, $decoder, $encoder, $description, $module)
2515 = $image->QueryFormat('gif');
2518 <p>Call MagickToMime() with the image format name to get its MIME type such as <kbd>images/tiff</kbd> from <kbd>tif</kbd>.</p>
2521 $mime = $image->MagickToMime('tif');
2524 <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>
2527 $image->RemoteCommand('image.jpg');
2530 <p>The Smush() method smushes a set of images together. For example,</p>
2533 $p = $image->Smush(stack=>{true,false},offset=><em>integer</em>);
2536 <p>smushes together all the images associated with object <kbd>$image</kbd>. By default, images are smushed left-to-right. Set <kbd>stack</kbd> to True to smushed them top-to-bottom.</p>
2538 <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>
2541 @statistics = $image->Statistics();
2544 <p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p>
2547 $p = $image->Transform(crop=>'100x100+0+0', gravity=>'Center');
2550 <p>You can optionally add <i>Image</i> to any method name above. For example, PingImage() is an alias for method Ping().</p>
2554 <h2><a id="exceptions"></a>Handling Exceptions</h2>
2555 <div class="doc-section">
2557 <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>
2559 <p>Methods which return a number (e.g. Read(), Write()):</p>
2562 $x = $image->Read(...);
2563 warn "$x" if "$x"; # print the error message
2565 print $1; # print the error number
2566 print 0+$x; # print the number of images read
2569 <p>Methods which operate on an image (e.g. Resize(), Crop()):</p>
2572 $x = $image->Crop(...);
2573 warn "$x" if "$x"; # print the error message
2575 print $1; # print the error number
2578 <p>Methods which return images (EvaluateSequence(), Montage(), Clone()) should be checked for errors this way:</p>
2581 $x = $image->Montage(...);
2582 warn "$x" if !ref($x); # print the error message
2584 print $1; # print the error number
2587 <p>Here is an example error message:</p>
2590 Error 400: Memory allocation failed
2593 <p>Review the complete list of <a href="../www/exception.html">error and warning codes</a>.</p>
2595 <p>The following illustrates how you can use a numeric status code:</p>
2598 $x = $image->Read('rose.png');
2600 die "unable to continue" if ($1 == ResourceLimitError);
2605 <h2><a id="constants"></a>Constants</h2>
2606 <div class="doc-section">
2608 <p>PerlMagick includes these constants:</p>
2631 MissingDelegateError
2632 MissingDelegateWarning
2643 ResourceLimitWarning
2655 <p>You can access them like this:</p>
2658 Image::Magick->QuantumDepth
2665 <div id="linkbar">
\r
2666 <span id="linkbar-west"> </span>
\r
2667 <span id="linkbar-center">
\r
2668 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> •
\r
2669 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
\r
2671 <span id="linkbar-east"> </span>
\r
2673 <div class="footer">
\r
2674 <span id="footer-west">© 1999-2011 ImageMagick Studio LLC</span>
\r
2675 <span id="footer-east"> <a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
\r
2677 <div style="clear: both; margin: 0; width: 100%; "></div>
\r
2678 <script type="text/javascript">
\r
2679 var _gaq = _gaq || [];
\r
2680 _gaq.push(['_setAccount', 'UA-17690367-1']);
\r
2681 _gaq.push(['_trackPageview']);
\r
2684 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
\r
2685 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
\r
2686 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
\r