Tryag File Manager
Home
-
Turbo Force
Current Path :
/
proc
/
self
/
root
/
usr
/
share
/
doc
/
ImageMagick-6.2.8
/
www
/
Upload File :
New :
File
Dir
//proc/self/root/usr/share/doc/ImageMagick-6.2.8/www/perl-magick.html
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <style type="text/css"><!-- @import url("../www/magick.css"); //--></style> <title>ImageMagick: PerlMagick, Perl API for ImageMagick</title> <meta http-equiv="Content-Language" content="en-US"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/> <meta name="Generator" content="PHP"/> <meta name="Keywords" content="perlmagick, perl, api, for, imagemagick, ImageMagick, PerlMagick, Magick++, Image, Magick"/> <meta name="Description" content="ImageMagick (TM) is a free software suite to create, edit and compose bitmap images. It can read, convert and write images in a large variety of formats. Images can be cropped, colors can be changed, various effects can be applied, images can be rotated and combined, and text, lines, polygons, ellipses and Bézier curves can be added to images and stretched and rotated. ImageMagick is free software: it is delivered with full source code and can be freely used, copied, modified and distributed. Its license is compatible with the GPL. It runs on all major operating systems. Most of the functionality of ImageMagick can be used interactively from the command line; more often, however, the features are used from programs written in the programming languages Perl, C, C++, Python, PHP, Ruby or Java, for which ready-made ImageMagick interfaces (PerlMagick, Magick++, PythonMagick, MagickWand for PHP, RubyMagick, and JMagick) are available. This makes it possible to modify or create images automatically and dynamically. ImageMagick supports many image formats (over 90 major formats) including popular formats like TIFF, JPEG, PNG, PDF, PhotoCD, and GIF."/> <meta name="Rating" content="GENERAL"/> <meta name="Robots" content="INDEX, FOLLOW"/> <meta name="Generator" content="ImageMagick Studio LLC"/> <meta name="Author" content="ImageMagick Studio LLC"/> <meta name="Revisit-after" content="2 DAYS"/> <meta name="Resource-type" content="document"/> <meta name="Copyright" content="Copyright (c) 1999-2006 ImageMagick Studio LLC"/> <meta name="Distribution" content="Global"/> <link rel="shortcut icon" href="/../images/wand.ico" type="image/x-icon"/> </head> <body id="www-imagemagick-org"> <table id="titlebar" style="width: 100%;background-color: #f5f5f5" cellpadding="0" cellspacing="0" border="0" summary="ImageMagick"> <tbody> <tr valign="top"> <td align="left"><a href="../index.html"><img id="titlebar-west" src="../images/script.png" alt="[ImageMagick]" width="350" height="60" border="0" vspace="28" name="titlebar-west" /></a></td> <td width="35%"><br /></td> <td align="left"><a href="http://www.imagemagick.org/" target="1175345236"><img id="titlebar-west" src="../images/sponsor.jpg" alt="[sponsor]" border="0" vspace="28" name="titlebar-west" /></a></td> <td width="65%"><br /></td> <td style="background-color: white" align="right"><a href="../index.html"><img src="../images/sprite.jpg" alt="" width="114" height="118" border="0" name="titlebar-east" /></a></td> <td style="background-color: white" align="right"><a href="../index.html"><img id="titlebar-east" src="../images/logo.jpg" alt="" width="114" height="118" border="0" name="titlebar-east" /></a></td> </tr> </tbody> </table> <table style="width: 100%" border="0" cellpadding="0" cellspacing="0" summary=""> <tbody> <tr valign="top" style="height: 100%;"> <td id="menu" width="1%" height="100%"> <p><a href="#main">Skip to page contents</a></p> <span>[</span> <a href="../index.html">About ImageMagick</a> <a href="../www/command-line-tools.html">Command-line Tools</a> <a href="../www/command-line-processing.html" class="sub">Processing</a> <a href="../www/command-line-options.html" class="sub">Options</a> <a href="../www/api.html">Program Interfaces</a> <a href="../www/magick-wand.html" class="sub">MagickWand</a> <a href="../www/magick-core.html" class="sub">MagickCore</a> <a href="../www/perl-magick.html" class="sub">PerlMagick</a> <a href="../www/architecture.html">Architecture</a> <span>]</span><br /><span>[</span> <a href="../www/install-source.html">Install from Source</a> <a href="../www/install-source.html#unix" class="sub">Unix</a> <a href="../www/install-source.html#windows" class="sub">Windows</a> <a href="../www/binary-releases.html">Binary Releases</a> <a href="../www/binary-releases.html#unix" class="sub">Unix</a> <a href="../www/binary-releases.html#windows" class="sub">Windows</a> <a href="../www/resources.html">Resources</a> <span>]</span><br /><span>[</span> <a href="../www/download.html">Download</a> <span>]</span><br /><span>[</span> <a href="../www/links.html">Links</a> <span>]</span><br /><br /><span>[</span> <a href="../www/sponsors.html">Sponsors</a> <a href="http://www.webservertalk.com" class="sponsor" target="sponsor">Server Administration<br />Support Forum</a><!-- 2007051536 pdt --> <span>]</span> </td> <td id="main" valign="top"> <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="#montage">Create an Image Montage</a> | <a href="#blobs">Working with Blobs</a> | <a href="#miscellaneous">Miscellaneous Methods</a> | <a href="#exceptions">Handling Exceptions</a> ]</p> <a name="introduction"></a> <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.2.0 or above and Perl version 5.005_02 or greater installed on your system for either of these utilities to work.</p> <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" target="1873322949">MagickStudio</a>, or use <a href="https://subversion.imagemagick.org/subversion/ImageMagick/trunk/PerlMagick/demo/" target="1247905699">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/" target="476166266">WebMagick Image Navigator</a>.</p> <p>You can try PerlMagick from your Web browser at the <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi" target="2003726360">ImageMagick Studio</a>. Or, you can see <a href="../www/examples.html">examples</a> of select PerlMagick functions.</p> <div style="margin: auto;"> <h2><a name="installation"></a>Installation</h2> </div> <p><b>UNIX</b></p> <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> <p>ImageMagick must already be installed on your system. Next, get the <a href="../www/download.html">PerlMagick</a> distribution corresponding to the installed ImageMagick distribution (e.g. PerlMagick 6.22 for ImageMagick 6.2.2) and unpack it as shown below:</p> <pre class="text"> gunzip -c PerlMagick-6.22.tar.gz | tar -xvf - cd PerlMagick </pre> <p>Next, edit <kbd>Makefile.PL</kbd> and change LIBS and INC to include the appropriate path information to the required <kbd>libMagick</kbd> library. You will also 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> <pre class="text"> perl Makefile.PL make make install </pre> <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> <p><b>Windows XP / Windows 2000</b></p> <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> <p>Next, type</p> <pre class="text"> cd PerlMagick copy Makefile.nt Makefile.PL perl Makefile.PL nmake nmake install </pre> <p>See the <a href="http://www.dylanbeattie.net/magick/">PerlMagick Windows HowTo</a> page for further installation instructions.</p> <p><b>Running the Regression Tests</b></p> <p>To verify a correct installation, type</p> <pre class="text"> make test </pre> <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> <pre class="text"> cd demo make </pre> <p>You are now ready to utilize the PerlMagick methods from within your Perl scripts.</p> <div style="margin: auto;"> <h2><a name="overview"></a>Overview</h2> </div> <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> <pre class="code"> use Image::Magick; $image=Image::Magick->new; </pre> <p>The new() method takes the same parameters as <a href="#set-attribute">SetAttribute</a> . For example,</p> <pre class="code"> $image=Image::Magick->new(size=>'384x256'); </pre> <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> <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 mega-bytes 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> <pre class="code"> undef $image; </pre> <p>To delete all the images but retain the <kbd>Image::Magick</kbd> object use</p> <pre class="code"> @$image = (); </pre> <p>and finally, to delete a single image from a multi-image sequence, use</p> <pre class="code"> undef $image->[$x]; </pre> <p>The next section illustrates how to use various PerlMagick methods to manipulate an image sequence.</p> <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,</p> <pre class="text"> $ENV{PATH}='/../bin:/usr/bin:/usr/local/bin'; </pre> <div style="margin: auto;"> <h2><a name="example"></a>Example Script</h2> </div> <p>Here is an example script to get you started:</p> <pre class="code"> #!/usr/local/bin/perl use Image::Magick;<br /> my($image, $x);<br /> $image = Image::Magick->new; $x = $image->Read('girl.png', 'logo.png', 'rose.png'); warn "$x" if "$x";<br /> $x = $image->Crop(geometry=>'100x100+100+100'); warn "$x" if "$x";<br /> $x = $image->Write('x.png'); warn "$x" if "$x"; </pre> <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 is done:</p> <pre class="code"> #!/usr/local/bin/perl use Image::Magick;<br /> my($image, $p, $q);<br /> $image = new Image::Magick; $image->Read('x1.png'); $image->Read('j*.jpg'); $image->Read('k.miff[1, 5, 3]'); $image->Contrast(); for ($x = 0; $image->[$x]; $x++) { $image->[$x]->Frame('100x200') if $image->[$x]->Get('magick') eq 'GIF'; undef $image->[$x] if $image->[$x]->Get('columns') < 100; } $p = $image->[1]; $p->Draw(stroke=>'red', primitive=>'rectangle', points=>20,20 100,100'); $q = $p->Montage(); undef $image; $q->Write('x.miff'); </pre> <p>Suppose you want to start out with a 100 by 100 pixel white canvas with a red pixel in the center. Try</p> <pre class="code"> $image = Image::Magick->new; $image->Set(size=>'100x100'); $image->ReadImage('xc:white'); $image->Set('pixel[49,49]'=>'red'); </pre> <p>Or suppose you want to convert your color image to grayscale:</p> <pre class="code"> $image->Quantize(colorspace=>'gray'); </pre> <p>Here we annotate an image with a Taipai TrueType font:</p> <pre class="code"> $text = 'Works like magick!'; $image->Annotate(font=>'kai.ttf', pointsize=>40, fill=>'green', text=>$text); </pre> <p>Other clever things you can do with a PerlMagick objects include</p> <pre class="code"> $i = $#$p"+1"; # return the number of images associated with object p push(@$q, @$p); # push the images from object p onto object q @$p = (); # delete the images but not the object p $p->Convolve([1, 2, 1, 2, 4, 2, 1, 2, 1]); # 3x3 Gaussian kernel </pre> <div style="margin: auto;"> <h2><a name="read"></a>Read or Write an Image</h2> </div> <p>Use the methods listed below to either read, write, or display an image or image sequence:</p> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Read or Write Methods</caption> <tbody> <tr> <th>Method</th> <th>Parameters</th> <th>Return Value</th> <th style="width: 50%">Description</th> </tr> <tr> <td>Read</td> <td>one or more filenames</td> <td>the number of images read</td> <td>read an image or image sequence</td> </tr> <tr> <td>Write</td> <td>filename</td> <td>the number of images written</td> <td>write an image or image sequence</td> </tr> <tr> <td>Display</td> <td>server name</td> <td>the number of images displayed</td> <td>display the image or image sequence to an X server</td> </tr> <tr> <td>Animate</td> <td>server name</td> <td>the number of images animated</td> <td>animate image sequence to an X server</td> </tr> </tbody> </table> <p>For convenience, methods Write(), Display(), and Animate() can take any parameter that <a href="#set-attribute">SetAttribute</a> knows about. For example,</p> <pre class="code"> $image->Write(filename=>'image.png', compression=>'None'); </pre> <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> <pre class="code"> binmode STDOUT; $image->Write('png:-'); </pre> <p>To read an image in the GIF format from a PERL filehandle, use:</p> <pre class="code"> $image = Image::Magick->new; open(IMAGE, 'image.gif'); $image->Read(file=>\*IMAGE); close(IMAGE); </pre> <p>To write an image in the PNG format to a PERL filehandle, use:</p> <pre class="code"> $filename = "image.png"; open(IMAGE, ">$filename"); $image->Write(file=>\*IMAGE, filename=>$filename); close(IMAGE); </pre> <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> <pre class="text"> image%03d.miff </pre> <p>converts files image000.miff, image001.miff, etc.</p> <p>You can optionally add <i>Image</i> to any method name. For example, ReadImage() is an alias for method Read().</p> <div style="margin: auto;"> <h2><a name="manipulate"></a>Manipulate an Image</h2> </div> <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> <pre class="code"> $image->Crop(geometry=>'100x100+10+20'); $image->[$x]->Frame("100x200"); </pre> <p>And here is a list of other image manipulation methods you can call:</p> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Image Manipulation Methods</caption> <tbody> <tr> <th>Method</th> <th style="width: 40%">Parameters</th> <th style="width: 40%">Description</th> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>AdaptiveSharpen</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>adaptively sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma). Increase the effect near edges.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>AdaptiveThreshold</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, offset=><i>integer</i></td> <td>local adaptive thresholding.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>AddNoise</td> <td>noise=>{Uniform, Gaussian, Multiplicative, Impulse, Laplacian, Poisson}, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>add noise to an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>AffineTransform</td> <td>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></td> <td>affine transform image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Annotate</td> <td>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>, 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}</td> <td>annotate an image with text. See <a href="#misc">QueryFontMetrics</a> to get font metrics without rendering any text.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>BlackThreshold</td> <td>threshold=><i>string</i></td> <td>force all pixels below the threshold intensity into black</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Blur</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>blur the image with a Gaussian operator of the given radius and standard deviation (sigma).</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Border</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><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, CopyCyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, 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> <td>surround the image with a border of color</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Charcoal</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i></td> <td>simulate a charcoal drawing</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Chop</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i></td> <td>chop an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Clip</td> <td>id=><i>name</i>, inside=><i>{true, false}</i>,</td> <td>apply along a named path from the 8BIM profile.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Coalesce</td> <td><br /></td> <td>merge a sequence of images</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>ColorFloodfill</td> <td>geometry=><i>geometry</i>, 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></td> <td>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> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Colorize</td> <td>fill=><i><a href="../www/color.html">color name</a></i>, opacity=><i>string</i></td> <td>colorize the image with the fill color</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Comment</td> <td>string</td> <td>add a comment to your image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Compare</td> <td>image=><i>image-handle</i></td> <td>compare image to a reference image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>CompareLayers</td> <td>method=>{any, clear, overlay}</td> <td>compares each image with the next in a sequence and returns the maximum bounding region of any pixel differences it discovers.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Composite</td> <td>image=><i>image-handle</i>, compose=>{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, 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></td> <td>composite one image onto another</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Contrast</td> <td>sharpen=>{True, False}</td> <td>enhance or reduce the image contrast</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>ContrastStretch</td> <td>levels=><i>string</i>, 'black-point'=><i>double</i>, 'white-point'=><i>double</i>, channel=>{Red, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td> <td>improve the contrast in an image by `stretching' the range of intensity values</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Convolve</td> <td>coefficients=><i>array of float values</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}, bias=>;<i>double</i></td> <td>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> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Crop</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, fuzz=><i>double</i></td> <td>crop an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>CycleColormap</td> <td>amount=><i>integer</i></td> <td>displace image colormap by amount</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Deconstruct</td> <td><br /></td> <td>break down an image sequence into constituent parts</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Despeckle</td> <td><br /></td> <td>reduce the speckles within an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Draw</td> <td>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>, tile=><i>image-handle</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>, 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></td> <td>annotate an image with one or more graphic primitives</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Edge</td> <td>radius=><i>double</i></td> <td>enhance edges within the image with a convolution filter of the given radius.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Emboss</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i></td> <td>emboss the image with a convolution filter of the given radius and standard deviation (sigma).</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Enhance</td> <td><br /></td> <td>apply a digital filter to enhance a noisy image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Equalize</td> <td><br /></td> <td>perform histogram equalization to the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Extent</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> <td>set the image size</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Evaluate</td> <td>value=><i>double</i>, operator=><i>{Add, And, Divide, LeftShift, Max, Min, Multiply, Or, Rightshift, Subtract, Xor}</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow} </td> <td>apply an arithmetic, relational, or logical expression to the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Flip</td> <td><br /></td> <td>create a <i>mirror image</i> by reflecting the image scanlines in the vertical direction</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Flop</td> <td><br /></td> <td>create a <i>mirror image</i> by reflecting the image scanlines in the horizontal direction</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Frame</td> <td>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, CopyCyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, 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> <td>surround the image with an ornamental border</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Gamma</td> <td>gamma=><i>string</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>gamma correct the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>GaussianBlur</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>blur the image with a Gaussian operator of the given radius and standard deviation (sigma).</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>GetPixels</td> <td>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> <td>get image pixels as defined by the map (e.g. "RGB", "RGBA", etc.). By default non-normalized pixel values are returned.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Identify</td> <td>file=><i>file</i></td> <td>identify the attributes of an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Implode</td> <td>amount=><i>double</i></td> <td>implode image pixels about the center</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Label</td> <td>string</td> <td>assign a label to an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Level</td> <td>levels=><i>string</i>, 'black-point'=><i>double</i>, 'gamma'=><i>double</i>, 'white-point'=><i>double</i>, channel=>{Red, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td> <td>adjust the level of image contrast</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Magnify</td> <td><br /></td> <td>double the size of an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Map</td> <td>image=><i>image-handle</i>, dither=>{True, False}</td> <td>choose a particular set of colors from this image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>MatteFloodfill</td> <td>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></td> <td>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> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>MedianFilter</td> <td>radius=><i>double</i></td> <td>replace each pixel with the median intensity pixel of a neighborhood.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Minify</td> <td><br /></td> <td>half the size of an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Modulate</td> <td>brightness=><i>double</i>, saturation=><i>double</i>, hue=><i>double</i>, luminosity=><i>double</i>, whiteness=><i>double</i>, blackness=><i>double</i> </td> <td>vary the brightness, saturation, and hue of an image by the specified percentage</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>MotionBlur</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, angle=><i>double</i></td> <td>blur the image with a Gaussian operator of the given radius and standard deviation (sigma) at the given angle to simulate the effect of motion</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Negate</td> <td>gray=>{True, False}, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>replace every pixel with its complementary color (white becomes black, yellow becomes blue, etc.)</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Normalize</td> <td>channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}<br /></td> <td>transform image to span the full range of color values</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>OilPaint</td> <td>radius=><i>integer</i></td> <td>simulate an oil painting</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Opaque</td> <td>color=><i><a href="../www/color.html">color name</a></i>, fill=><i><a href="../www/color.html">color name</a></i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>change this color to the fill color within the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>OptimizeLayers</td> <td><br /></td> <td>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> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Posterize</td> <td>levels=><i>integer</i>, dither=>{True, False}</td> <td>reduce the image to a limited number of color level</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Profile</td> <td>name=><i>string</i>, profile=><i>blob</i>, rendering-intent=>{Undefined, Saturation, Perceptual, Absolute, Relative}, black-point-compensation=>{True, False}</td> <td>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> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Quantize</td> <td>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}, measure_error=>{True, False}, global_colormap=>{True, False}</td> <td>preferred number of colors in the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>RadialBlur</td> <td>angle=><i>double</i></td> <td>radial blur the image.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Raise</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, raise=>{True, False}</td> <td>lighten or darken image edges to create a 3-D effect</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>ReduceNoise</td> <td>radius=><i>double</i></td> <td>reduce noise in the image with a noise peak elimination filter</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Resample</td> <td>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> <td>resample image to desired resolution. Specify <kbd>blur</kbd> > 1 for blurry or < 1 for sharp</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Resize</td> <td>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></td> <td>scale image to desired size. Specify <kbd>support</kbd> > 1 for blurry or < 1 for sharp</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Roll</td> <td>geometry=><i>geometry</i>, x=><i>integer</i>, y=><i>integer</i></td> <td>roll an image vertically or horizontally</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Rotate</td> <td>degrees=><i>double</i>, color=><i><a href="../www/color.html">color name</a></i></td> <td>rotate an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Sample</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> <td>scale image with pixel sampling</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Scale</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> <td>scale image to desired size</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Segment</td> <td>colorspace=>{RGB, Gray, Transparent, OHTA, XYZ, YCbCr, YCC, YIQ, YPbPr, YUV, CMYK}, verbose={True, False}, cluster=><i>double</i>, smooth=<i>double</i></td> <td>segment an image by analyzing the histograms of the color components and identifying units that are homogeneous</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Separate</td> <td>channel=>{Red, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}</td> <td>separate a channel from the image into a grayscale image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Shade</td> <td>geometry=><i>geometry</i>, azimuth=><i>double</i>, elevation=><i>double</i>, gray=>{true, false}</td> <td>shade the image using a distant light source</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Shadow</td> <td>geometry=><i>geometry</i>, opacity=><i>double</i>, sigma=><i>double</i>, x=><i>integer</i>, y=><i>integer</i></td> <td>simulate an image shadow</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Sharpen</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma).</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Shave</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> <td>shave pixels from the image edges</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Shear</td> <td>geometry=><i>geometry</i>, x=><i>double</i>, y=><i>double</i> color=><i><a href="../www/color.html">color name</a></i></td> <td>shear the image along the X or Y axis by a positive or negative shear angle</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>SigmoidalContrast</td> <td>geometry=><i>string</i>, 'contrast'=><i>double</i>, 'mid-point'=><i>double</i> channel=>{Red, Cyan, Green, Magenta, Blue, Yellow, Opacity, Black, or All}, sharpen=>{True, False}</td> <td>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> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Signature</td> <td><br /></td> <td>generate an SHA-256 message digest for the image pixel stream</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Solarize</td> <td>threshold=><i>double</i></td> <td>negate all pixels above the threshold level</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Splice</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, fuzz=><i>double</i></td> <td>splice an image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Spread</td> <td>amount=><i>double</i></td> <td>displace image pixels by a random amount</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Stegano</td> <td>image=><i>image-handle</i>, offset=><i>integer</i></td> <td>hide a digital watermark within the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Stereo</td> <td>image=><i>image-handle</i></td> <td>composites two images and produces a single image that is the composite of a left and right image of a stereo pair</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Strip</td> <td><br /></td> <td>strip an image of all profiles and comments.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Swirl</td> <td>degrees=><i>double</i></td> <td>swirl image pixels about the center</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Texture</td> <td>texture=><i>image-handle</i></td> <td>name of texture to tile onto the image background</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Thumbnail</td> <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> <td>changes the size of an image to the given dimensions and removes any associated profiles.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Threshold</td> <td>threshold=><i>string</i>, channel=>{All, alpha, Black, Blue, Cyan, Gray, Green, Index, Magenta, Opacity, Red, Yellow}</td> <td>threshold the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Tint</td> <td>fill=><i><a href="../www/color.html">color name</a></i>, opacity=><i>string</i></td> <td>tint the image with the fill color.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Transparent</td> <td>color=><i><a href="../www/color.html">color name</a></i></td> <td>make this color transparent within the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Trim</td> <td><br /></td> <td>remove edges that are the background color from the image</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>UnsharpMask</td> <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, amount=><i>double</i>, threshold=><i>double</i></td> <td>sharpen the image with the unsharp mask algorithm.</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Vignette</td> <td>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> <td>offset the edges of the image in vignette style</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>Wave</td> <td>geometry=><i>geometry</i>, amplitude=><i>double</i>, wavelength=><i>double</i></td> <td>alter an image along a sine wave</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> <tr> <td>WhiteThreshold</td> <td>threshold=><i>string</i></td> <td>force all pixels above the threshold intensity into white</td> </tr> <tr> <td><hr /></td> <td><hr /></td> <td><hr /></td> </tr> </tbody> </table> <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> <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> <pre class="code"> $image->Draw(fill=>'red', primitive=>'rectangle', points=>'20,20 100,100 40,40 200,200 60,60 300,300'); </pre> <p>Is equivalent to</p> <pre class="code"> $image->Draw(fill=>'red', primitive=>'@draw.txt'); </pre> <p>Where <kbd>draw.txt</kbd> is a file on disk that contains this:</p> <pre class="text"> rectangle 20, 20 100, 100 rectangle 40, 40 200, 200 rectangle 60, 60 300, 300 </pre> <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> <pre class="text"> %b file size %c comment %d directory %e filename extension %f filename %g page geometry %h height %i input filename %k number of unique colors %l label %m magick %n number of scenes %o output filename %p page number %q quantum depth %r image class and colorspace %s scene number %t top of filename %u unique temporary filename %w width %x x resolution %y y resolution %z image depth %D image dispose method %O page offset %P page width and height %Q image compression quality %@ bounding box %# signature %% a percent sign \n newline \r carriage return </pre> <p>For example,</p> <pre class="text"> text=>"%m:%f %wx%h" </pre> <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> <p>You can optionally add <i>Image</i> to any method name. For example, TrimImage() is an alias for method Trim().</p> <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> <div style="margin: auto;"> <h2><a name="set-attribute"></a>Set an Image Attribute</h2> </div> <p>Use method Set() to set an image attribute. For example,</p> <pre class="code"> $image->Set(dither=>'True'); $image->[$x]->Set(delay=>3); </pre> <p>Where this example uses 'True' and this document says '{True, False}', you can use the case-insensitive strings 'True' and 'False', or you can use the integers 1 and 0.</p> <p>When you call Get() on a Boolean attribute, Image::Magick returns 1 or 0, not a string.</p> <p>And here is a list of all the image attributes you can set:</p> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Image Attributes</caption> <tbody> <tr> <th>Attribute</th> <th style="width: 40%">Values</th> <th style="width: 40%">Description</th> </tr> <tr> <td>adjoin</td> <td>{True, False}</td> <td>join images into a single multi-image file</td> </tr> <tr> <td>antialias</td> <td>{True, False}</td> <td>remove pixel aliasing</td> </tr> <tr> <td>area-limit</td> <td><i>integer</i></td> <td>set pixel area resource limit in megabytes.</td> </tr> <tr> <td>authenticate</td> <td><i>string</i></td> <td>decrypt image with this password.</td> </tr> <tr> <td>background</td> <td><i><a href="../www/color.html">color name</a></i></td> <td>image background color</td> </tr> <tr> <td>blue-primary</td> <td><i>x-value</i>, <i>y-value</i></td> <td>chromaticity blue primary point (e.g. 0.15, 0.06)</td> </tr> <tr> <td>bordercolor</td> <td><i><a href="../www/color.html">color name</a></i></td> <td>set the image border color</td> </tr> <tr> <td>clip-mask</td> <td><i>image</i></td> <td>Associate a clip mask with the image.</td> </tr> <tr> <td>colormap[<i>i</i>]</td> <td><i><a href="../www/color.html">color name</a></i></td> <td>color name (e.g. red) or hex value (e.g. #ccc) at position <i>i</i></td> </tr> <tr> <td>colorspace</td> <td>{RGB, CMYK}</td> <td>type of colorspace</td> </tr> <tr> <td>compression</td> <td>{None, BZip, Fax, Group4, JPEG, JPEG2000, LosslessJPEG, LZW, RLE, Zip}</td> <td>type of image compression</td> </tr> <tr> <td>debug</td> <td>{All, Annotate, Blob, Cache, Coder, Configure, Deprecate, Draw, Exception, Locale, None, Resource, Transform, X11}</td> <td>display copious debugging information</td> </tr> <tr> <td>delay</td> <td><i>integer</i></td> <td>this many 1/100ths of a second must expire before displaying the next image in a sequence</td> </tr> <tr> <td>density</td> <td><i>geometry</i></td> <td>vertical and horizontal resolution in pixels of the image</td> </tr> <tr> <td>depth</td> <td><i>integer</i></td> <td>image depth</td> </tr> <tr> <td>disk-limit</td> <td><i>integer</i></td> <td>set disk resource limit in megabytes</td> </tr> <tr> <td>dispose</td> <td><i>{Undefined, None, Background, Previous}</i></td> <td>GIF disposal method</td> </tr> <tr> <td>dither</td> <td>{True, False}</td> <td>apply error diffusion to the image</td> </tr> <tr> <td>display</td> <td><i>string</i></td> <td>specifies the X server to contact</td> </tr> <tr> <td>extract</td> <td><i>geometry</i></td> <td>extract area from image</td> </tr> <tr> <td>file</td> <td><i>filehandle</i></td> <td>set the image filehandle</td> </tr> <tr> <td>filename</td> <td><i>string</i></td> <td>set the image filename</td> </tr> <tr> <td>fill</td> <td><i>color</i></td> <td>The fill color paints any areas inside the outline of drawn shape.</td> </tr> <tr> <td>font</td> <td><i>string</i></td> <td>use this font when annotating the image with text</td> </tr> <tr> <td>fuzz</td> <td><i>integer</i></td> <td>colors within this distance are considered equal</td> </tr> <tr> <td>gamma</td> <td><i>double</i></td> <td>gamma level of the image</td> </tr> <tr> <td>Gravity</td> <td>{Forget, NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> <td>type of image gravity</td> </tr> <tr> <td>green-primary</td> <td><i>x-value</i>, <i>y-value</i></td> <td>chromaticity green primary point (e.g. 0.3, 0.6)</td> </tr> <tr> <td>index[<i>x</i>, <i>y</i>]</td> <td><i>string</i></td> <td>colormap index at position (<i>x</i>, <i>y</i>)</td> </tr> <tr> <td>interlace</td> <td>{None, Line, Plane, Partition}</td> <td>the type of interlacing scheme</td> </tr> <tr> <td>iterations</td> <td><i>integer</i></td> <td>add Netscape loop extension to your GIF animation</td> </tr> <tr> <td>loop</td> <td><i>integer</i></td> <td>add Netscape loop extension to your GIF animation</td> </tr> <tr> <td>magick</td> <td><i>string</i></td> <td>set the image format</td> </tr> <tr> <td>matte</td> <td>{True, False}</td> <td>enable the image matte channel</td> </tr> <tr> <td>mattecolor</td> <td><i><a href="../www/color.html">color name</a></i></td> <td>set the image matte color</td> </tr> <tr> <td>map-limit</td> <td><i>integer</i></td> <td>set map resource limit in megabytes</td> </tr> <tr> <td>memory-limit</td> <td><i>integer</i></td> <td>set memory resource limit in megabytes</td> </tr> <tr> <td>monochrome</td> <td>{True, False}</td> <td>transform the image to black and white</td> </tr> <tr> <td>option</td> <td><i>string</i></td> <td>associate an option with an image format (e.g. option=>'ps:imagemask'</td> </tr> <tr> <td>orientation</td> <td>{top-left, top-right, bottom-right, bottom-left, left-top, right-top, right-bottom, left-bottom}</td> <td>image orientation</td> </tr> <tr> <td>page</td> <td>{ Letter, Tabloid, Ledger, Legal, Statement, Executive, A3, A4, A5, B4, B5, Folio, Quarto, 10x14} or <i>geometry</i></td> <td>preferred size and location of an image canvas</td> </tr> <tr> <td>pixel[<i>x</i>, <i>y</i>]</td> <td><i>string</i></td> <td>hex value (e.g. #ccc) at position (<i>x</i>, <i>y</i>)</td> </tr> <tr> <td>pointsize</td> <td><i>integer</i></td> <td>pointsize of the Postscript or TrueType font</td> </tr> <tr> <td>quality</td> <td><i>integer</i></td> <td>JPEG/MIFF/PNG compression level</td> </tr> <tr> <td>red-primary</td> <td><i>x-value</i>, <i>y-value</i></td> <td>chromaticity red primary point (e.g. 0.64, 0.33)</td> </tr> <tr> <td>sampling-factor</td> <td><i>geometry</i></td> <td>horizontal and vertical sampling factor</td> </tr> <tr> <td>scene</td> <td><i>integer</i></td> <td>image scene number</td> </tr> <tr> <td>server</td> <td><i>string</i></td> <td>specifies the X server to contact</td> </tr> <tr> <td>size</td> <td><i>string</i></td> <td>width and height of a raw image</td> </tr> <tr> <td>stroke</td> <td><i>color</i></td> <td>The stroke color paints along the outline of a shape.</td> </tr> <tr> <td>texture</td> <td><i>string</i></td> <td>name of texture to tile onto the image background</td> </tr> <tr> <td>type</td> <td>{Bilevel, Grayscale, GrayscaleMatte, Palette, PaletteMatte, TrueColor, TrueColorMatte, ColorSeparation, ColorSeparationMatte, Optimize }</td> <td>image type</td> </tr> <tr> <td>units</td> <td>{ Undefined, PixelsPerInch, PixelsPerCentimeters}</td> <td>units of image resolution</td> </tr> <tr> <td>verbose</td> <td>{True, False}</td> <td>print detailed information about the image</td> </tr> <tr> <td>virtual-pixel</td> <td>{Background, Edge, Mirror, Tile, Transparent}</td> <td>the virtual pixel method</td> </tr> <tr> <td>white-point</td> <td><i>x-value</i>, <i>y-value</i></td> <td>chromaticity white point (e.g. 0.3127, 0.329)</td> </tr> </tbody> </table> <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> <p>SetAttribute() is an alias for method Set().</p> <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> <div style="margin: auto;"> <h2><a name="get-attribute"></a>Get an Image Attribute</h2> </div> <p>Use method Get() to get an image attribute. For example,</p> <pre class="code"> ($a, $b, $c) = $image->Get('colorspace', 'magick', 'adjoin'); $width = $image->[3]->Get('columns'); </pre> <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> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Image Attributes</caption> <tbody> <tr> <th>Attribute</th> <th>Values</th> <th style="width: 60%">Description</th> </tr> <tr> <td>area</td> <td><i>integer</i></td> <td>current area resource consumed</td> </tr> <tr> <td>base-columns</td> <td><i>integer</i></td> <td>base image width (before transformations)</td> </tr> <tr> <td>base-filename</td> <td><i>string</i></td> <td>base image filename (before transformations)</td> </tr> <tr> <td>base-rows</td> <td><i>integer</i></td> <td>base image height (before transformations)</td> </tr> <tr> <td>class</td> <td>{Direct, Pseudo}</td> <td>image class</td> </tr> <tr> <td>colors</td> <td><i>integer</i></td> <td>number of unique colors in the image</td> </tr> <tr> <td>comment</td> <td><i>string</i></td> <td>get the image comment</td> </tr> <tr> <td>columns</td> <td><i>integer</i></td> <td>image width</td> </tr> <tr> <td>copyright</td> <td><i>string</i></td> <td>get PerlMagick's copyright</td> </tr> <tr> <td>directory</td> <td><i>string</i></td> <td>tile names from within an image montage</td> </tr> <tr> <td>elapsed-time</td> <td><i>double</i></td> <td>elapsed time in seconds since the image was created</td> </tr> <tr> <td>error</td> <td><i>double</i></td> <td>the mean error per pixel computed with methods Compare() or Quantize()</td> </tr> <tr> <td>bounding-box</td> <td><i>string</i></td> <td>image bounding box</td> </tr> <tr> <td>disk</td> <td><i>integer</i></td> <td>current disk resource consumed</td> </tr> <tr> <td>filesize</td> <td><i>integer</i></td> <td>number of bytes of the image on disk</td> </tr> <tr> <td>format</td> <td><i>string</i></td> <td>get the descriptive image format</td> </tr> <tr> <td>geometry</td> <td><i>string</i></td> <td>image geometry</td> </tr> <tr> <td>height</td> <td><i>integer</i></td> <td>the number of rows or height of an image</td> </tr> <tr> <td>id</td> <td><i>integer</i></td> <td>ImageMagick registry id</td> </tr> <tr> <td>label</td> <td><i>string</i></td> <td>image label</td> </tr> <tr> <td>mean-error</td> <td><i>double</i></td> <td>the normalized mean error per pixel computed with methods Compare() or Quantize()</td> </tr> <tr> <td>map</td> <td><i>integer</i></td> <td>current memory-mapped resource consumed</td> </tr> <tr> <td>matte</td> <td>{True, False}</td> <td>whether or not the image has a matte channel</td> </tr> <tr> <td>maximum-error</td> <td><i>double</i></td> <td>the normalized max error per pixel computed with methods Compare() or Quantize()</td> </tr> <tr> <td>memory</td> <td><i>integer</i></td> <td>current memory resource consumed</td> </tr> <tr> <td>mime</td> <td><i>string</i></td> <td>MIME of the image format</td> </tr> <tr> <td>montage</td> <td><i>geometry</i></td> <td>tile size and offset within an image montage</td> </tr> <tr> <td>rows</td> <td><i>integer</i></td> <td>the number of rows or height of an image</td> </tr> <tr> <td>signature</td> <td><i>string</i></td> <td>SHA-256 message digest associated with the image pixel stream</td> </tr> <tr> <td>taint</td> <td>{True, False}</td> <td>True if the image has been modified</td> </tr> <tr> <td>user-time</td> <td><i>double</i></td> <td>user time in seconds since the image was created</td> </tr> <tr> <td>version</td> <td><i>string</i></td> <td>get PerlMagick's version</td> </tr> <tr> <td>width</td> <td><i>integer</i></td> <td>the number of columns or width of an image</td> </tr> <tr> <td>x-resolution</td> <td><i>integer</i></td> <td>x resolution of the image</td> </tr> <tr> <td>y-resolution</td> <td><i>integer</i></td> <td>y resolution of the image</td> </tr> </tbody> </table> <p>GetAttribute() is an alias for method Get().</p> <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> <div style="margin: auto;"> <h2><a name="montage"></a>Create an Image Montage</h2> </div> <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> <pre class="code"> $image->Montage(geometry=>'160x160', tile=>'2x2', texture=>'granite:'); </pre> <p>And here is a list of Montage() parameters you can set:</p> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Montage Parameters</caption> <tbody> <tr> <th>Parameter</th> <th style="width: 40%">Values</th> <th style="width: 40%">Description</th> </tr> <tr> <td>background</td> <td><i><a href="../www/color.html">color name</a></i></td> <td>background color name</td> </tr> <tr> <td>border</td> <td><i>integer</i></td> <td>image border width</td> </tr> <tr> <td>filename</td> <td><i>string</i></td> <td>name of montage image</td> </tr> <tr> <td>fill</td> <td><a href="../www/color.html">color name</a></td> <td>fill color for annotations</td> </tr> <tr> <td>font</td> <td><i>string</i></td> <td>X11 font name</td> </tr> <tr> <td>frame</td> <td><i>geometry</i></td> <td>surround the image with an ornamental border</td> </tr> <tr> <td>geometry</td> <td><i>geometry</i></td> <td>preferred tile and border size of each tile of the composite image (e.g. 120x120+4+3>)</td> </tr> <tr> <td>gravity</td> <td>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> <td>direction image gravitates to within a tile</td> </tr> <tr> <td>label</td> <td><i>string</i></td> <td>assign a label to an image</td> </tr> <tr> <td>mode</td> <td>{Frame, Unframe, Concatenate}</td> <td>thumbnail framing options</td> </tr> <tr> <td>pointsize</td> <td><i>integer</i></td> <td>pointsize of the Postscript or TrueType font</td> </tr> <tr> <td>shadow</td> <td>{True, False}</td> <td>add a shadow beneath a tile to simulate depth</td> </tr> <tr> <td>stroke</td> <td><a href="../www/color.html">color name</a></td> <td>stroke color for annotations</td> </tr> <tr> <td>texture</td> <td><i>string</i></td> <td>name of texture to tile onto the image background</td> </tr> <tr> <td>tile</td> <td><i>geometry</i></td> <td>the number of tiles per row and page (e.g. 6x4)</td> </tr> <tr> <td>title</td> <td>string</td> <td>assign a title to the image montage</td> </tr> <tr> <td>transparent</td> <td><i>string</i></td> <td>make this color transparent within the image</td> </tr> </tbody> </table> <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> <p>MontageImage() is an alias for method Montage().</p> <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> <div style="margin: auto;"> <h2><a name="blobs"></a>Working with Blobs</h2> </div> <p>A blob contains data that directly represent a particular image format in memory instead of on disk. PerlMagick supports 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> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Blob Methods</caption> <tbody> <tr> <th>Method</th> <th>Parameters</th> <th>Return Value</th> <th style="width: 50%">Description</th> </tr> <tr> <td>ImageToBlob</td> <td>any image <a href="#set-attribute">attribute</a></td> <td>an array of image data in the respective image format</td> <td>convert an image or image sequence to an array of blobs</td> </tr> <tr> <td>BlobToImage</td> <td>one or more blobs</td> <td>the number of blobs converted to an image</td> <td>convert one or more blobs to an image</td> </tr> </tbody> </table> <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> <pre class="code"> @blobs = $image->ImageToBlob(); open(DISPLAY,"| display -") || die; binmode DISPLAY; print DISPLAY $blobs[0]; close DISPLAY; </pre> <p>Method BlobToImage() returns an image or image sequence converted from the supplied blob:</p> <pre class="code"> @blob=$db->GetImage(); $image=Image::Magick->new(magick=>'jpg'); $image->BlobToImage(@blob); </pre> <div style="margin: auto;"> <h2><a name="miscellaneous"></a>Miscellaneous Methods</h2> </div> <p>The Append() method append a set of images. For example,</p> <pre class="code"> $p = $image->Append(stack=>{true,false}); </pre> <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> <p>The Average() method averages a set of images. For example,</p> <pre class="code"> $p = $image->Average(); </pre> <p>averages all the images associated with object <kbd>$image</kbd>.</p> <p>The Clone() method copies a set of images. For example,</p> <pre class="code"> $p = $image->Clone(); </pre> <p>copies all the images from object <kbd>$q</kbd> to <kbd>$p</kbd>. You can use this method for single or multi-image sequences.</p> <p>The Flatten() method flattens a set of images. For example,</p> <pre class="code"> $p = $images->Flatten(background=>'none'); </pre> <p>The sequence of images is replaced by a single image created by composing each image after the first over the first image.</p> <p>The Fx() method applies a mathematical expression to a set of images. For example,</p> <pre class="code"> $p = $image->Fx(expression=>'(g+b)/2.0',channel=>'red'); </pre> <p>replaces the red channel with the average of the green and blue channels.</p> <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> <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> <pre class="code"> $p = $image->Morph(frames=><i>integer</i>); </pre> <p>where <i>frames</i> is the number of in-between images to generate. The default is 1.</p> <p>Mosaic() creates an mosaic from an image sequence.</p> <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> <pre class="code"> $image->Crop('340x256+0+0'); $image->Mogrify('crop', '340x256+0+0'); </pre> <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> <pre class="code"> $image->MogrifyRegion('100x100+40+50', 'modulate', brightness=>50); </pre> <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> <pre class="code"> ($width, $height, $size, $format) = $image->Ping('logo.png'); ($width, $height, $size, $format) = $image->Ping(file=>\*IMAGE); ($width, $height, $size, $format) = $image->Ping(blob=>$blob); </pre> <p>This is 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> <pre class="code"> $preview = $image->Preview('Gamma'); $preview->Display(); </pre> <p>To have full control over text positioning you need font metric information. Use</p> <pre class="code"> ($x_ppem, $y_ppem, $ascender, $descender, $width, $height, $max_advance) = $image->QueryFontMetrics(<i>parameters</i>); </pre> <p>Where <i>parameters</i> is any parameter of the <a href="#manipulate">Annotate</a> method. The return values are:</p> <ul> <li>character width</li> <li>character height</li> <li>ascender</li> <li>descender</li> <li>text width</li> <li>text height</li> <li>maximum horizontal advance</li> </ul> <p>Use QueryMultilineFontMetrics() to get the maximum text width and height for multiple lines of text.</p> <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> <pre class="code"> @colors = $image->QueryColor(); ($red, $green, $blue, $opacity) = $image->QueryColor('cyan'); ($red, $green, $blue, $opacity) = $image->QueryColor('#716bae'); </pre> <p>QueryColorname() accepts a color value and returns its respective name or hex value;</p> <pre class="code"> $name = $image->QueryColorname('rgba(80,60,0,0)'); </pre> <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> <pre class="code"> @fonts = $image->QueryFont(); $weight = ($image->QueryFont('Helvetica'))[5]; </pre> <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> <pre class="code"> @formats = $image->QueryFormat(); ($adjoin, $blob_support, $raw, $decoder, $encoder, $description, $module) = $image->QueryFormat('gif'); </pre> <p>Call MagickToMime() with the image format name to get its MIME type such as <kbd>image/tiff</kbd> from <kbd>tif</kbd>.</p> <pre class="code"> $mime = $image->MagickToMime('tif'); </pre> <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> <pre class="code"> $image->RemoteCommand('image.jpg'); </pre> <p>Statistics() returns the image statistics for each channel in the image. The returned values are an array of depth, minima, maxima, mean, and standard deviation values in RGB, CMYK, RGBA, or CMYKA order (depending on the image type).</p> <pre class="code"> @statistics = $image->Statistics(); </pre> <p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p> <pre class="code"> $p = $image->Transform(crop=>'100x100'); </pre> <p>You can optionally add <i>Image</i> to any method name above. For example, PingImage() is an alias for method Ping().</p> <div style="margin: auto;"> <h2><a name="exceptions"></a>Handling Exceptions</h2> </div> <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> <p>Methods which return a number (e.g. Read(), Write()):</p> <pre class="code"> $x = $image->Read(...); warn "$x" if "$x"; # print the error message $x =~ /(\d+)/; print $1; # print the error number print 0+$x; # print the number of images read </pre> <p>Methods which operate on an image (e.g. Resize(), Crop()):</p> <pre class="code"> $x = $image->Crop(...); warn "$x" if "$x"; # print the error message $x =~ /(\d+)/; print $1; # print the error number </pre> <p>Methods which return images (Average(), Montage(), Clone()) should be checked for errors this way:</p> <pre class="code"> $x = $image->Montage(...); warn "$x" if !ref($x); # print the error message $x =~ /(\d+)/; print $1; # print the error number </pre> <p>Here is an example error message:</p> <pre class="code"> Error 400: Memory allocation failed </pre> <p>Below is a list of error and warning codes:</p> <table style="width: 100%" id="table" cellpadding="2" cellspacing="0"> <caption>Error and Warning Codes</caption> <tbody> <tr> <th>Code</th> <th>Mnemonic</th> <th style="width: 60%">Description</th> </tr> <tr> <td>0</td> <td>Success</td> <td>method completed without an error or warning</td> </tr> <tr> <td>300</td> <td>ResourceLimitWarning</td> <td>a program resource is exhausted (e.g. not enough memory)</td> </tr> <tr> <td>305</td> <td>TypeWarning</td> <td>A font is unavailable; a substitution may have occurred</td> </tr> <tr> <td>310</td> <td>OptionWarning</td> <td>a command-line option was malformed</td> </tr> <tr> <td>315</td> <td>DelegateWarning</td> <td>an ImageMagick <i>delegate</i> returned a warning</td> </tr> <tr> <td>320</td> <td>MissingDelegateWarning</td> <td>the image type can not be read or written because the appropriate <i>Delegate</i> is missing</td> </tr> <tr> <td>325</td> <td>CorruptImageWarning</td> <td>the image file may be corrupt</td> </tr> <tr> <td>330</td> <td>FileOpenWarning</td> <td>the image file could not be opened</td> </tr> <tr> <td>335</td> <td>BlobWarning</td> <td>a binary large object could not be allocated</td> </tr> <tr> <td>340</td> <td>StreamWarning</td> <td>there was a problem reading or writing from a stream</td> </tr> <tr> <td>345</td> <td>CacheWarning</td> <td>pixels could not be saved to the pixel cache</td> </tr> <tr> <td>350</td> <td>CoderWarning</td> <td>there was a problem with an image coder</td> </tr> <tr> <td>355</td> <td>ModuleWarning</td> <td>there was a problem with an image module</td> </tr> <tr> <td>360</td> <td>DrawWarning</td> <td>a drawing operation failed</td> </tr> <tr> <td>365</td> <td>ImageWarning</td> <td>the operation could not complete due to an incompatible image</td> </tr> <tr> <td>380</td> <td>XServerWarning</td> <td>an X resource is unavailable</td> </tr> <tr> <td>385</td> <td>MonitorWarning</td> <td>there was a problem with prgress monitor</td> </tr> <tr> <td>390</td> <td>ConfigureWarning</td> <td>there was a problem getting a configuration file</td> </tr> <tr> <td>395</td> <td>RegistryWarning</td> <td>there was a problem getting or setting the registry</td> </tr> <tr> <td>400</td> <td>ResourceLimitError</td> <td>a program resource is exhausted (e.g. not enough memory)</td> </tr> <tr> <td>405</td> <td>TypeError</td> <td>A font is unavailable; a substitution may have occurred</td> </tr> <tr> <td>410</td> <td>OptionError</td> <td>a command-line option was malformed</td> </tr> <tr> <td>415</td> <td>DelegateError</td> <td>an ImageMagick <i>delegate</i> returned a warning</td> </tr> <tr> <td>420</td> <td>MissingDelegateError</td> <td>the image type can not be read or written because the appropriate <i>Delegate</i> is missing</td> </tr> <tr> <td>425</td> <td>CorruptImageError</td> <td>the image file may be corrupt</td> </tr> <tr> <td>430</td> <td>FileOpenError</td> <td>the image file could not be opened</td> </tr> <tr> <td>435</td> <td>BlobError</td> <td>a binary large object could not be allocated</td> </tr> <tr> <td>440</td> <td>StreamError</td> <td>there was a problem reading or writing from a stream</td> </tr> <tr> <td>445</td> <td>CacheError</td> <td>pixels could not be saved to the pixel cache</td> </tr> <tr> <td>450</td> <td>CoderError</td> <td>there was a problem with an image coder</td> </tr> <tr> <td>455</td> <td>ModuleError</td> <td>there was a problem with an image module</td> </tr> <tr> <td>460</td> <td>DrawError</td> <td>a drawing operation failed</td> </tr> <tr> <td>465</td> <td>ImageError</td> <td>the operation could not complete due to an incompatible image</td> </tr> <tr> <td>480</td> <td>XServerError</td> <td>an X resource is unavailable</td> </tr> <tr> <td>485</td> <td>MonitorError</td> <td>there was a progress monitor error</td> </tr> <tr> <td>490</td> <td>ConfigureError</td> <td>there was a problem getting a configuration file</td> </tr> <tr> <td>495</td> <td>RegistryError</td> <td>there was a problem getting or setting the registry</td> </tr> </tbody> </table> <p>The following illustrates how you can use a numeric status code:</p> <pre class="code"> $x = $image->Read('rose.png'); $x =~ /(\d+)/; die "unable to continue" if ($1 == ResourceLimitError); </pre> </td> <td id="margin" width="1%" height="100%" valign="top" align="right"> </td> </tr> </tbody> </table> <div id="linkbar"> <a href="http://redux.imagemagick.org/discussion-server" target="1201393768">Discourse Server</a> | <a href="../www/mailing-list.html">Mailing Lists</a> | <a href="http://redux.imagemagick.org/gallery" target="321262076">Image Gallery</a> | <a href="http://redux.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi" target="1825571782">ImageMagick Studio</a> </div> <div> <span id="footer-west">© 1999-2006 ImageMagick Studio LLC</span> </div> <div style="clear: both; margin: 0; width: 100%; "></div> </body> </html>