1 2 3 4 5<!DOCTYPE html> 6<html lang="en"> 7<head> 8 <meta charset="utf-8" /> 9 <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no" /> 10 <title>PerlMagick, Perl API @ ImageMagick</title> 11 <meta name="application-name" content="ImageMagick" /> 12 <meta name="description" content="Use ImageMagick® to create, edit, compose, or convert bitmap images. You can resize your image, crop it, change its shades and colors, add captions, among other operations." /> 13 <meta name="application-url" content="https://imagemagick.org" /> 14 <meta name="generator" content="PHP" /> 15 <meta name="keywords" content="perlmagick, perl, api, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert" /> 16 <meta name="rating" content="GENERAL" /> 17 <meta name="robots" content="INDEX, FOLLOW" /> 18 <meta name="generator" content="ImageMagick Studio LLC" /> 19 <meta name="author" content="ImageMagick Studio LLC" /> 20 <meta name="revisit-after" content="2 DAYS" /> 21 <meta name="resource-type" content="document" /> 22 <meta name="copyright" content="Copyright (c) 1999-2019 ImageMagick Studio LLC" /> 23 <meta name="distribution" content="Global" /> 24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" /> 25 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" /> 26 <link href="perl-magick.html" rel="canonical" /> 27 <link href="../images/wand.png" rel="icon" /> 28 <link href="../images/wand.ico" rel="shortcut icon" /> 29 <link href="assets/magick.css" rel="stylesheet" /> 30</head> 31<body> 32 <header> 33 <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark"> 34 <a class="navbar-brand" href="../"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../images/wand.ico"/></a> 35 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation"> 36 <span class="navbar-toggler-icon"></span> 37 </button> 38 39 <div class="navbar-collapse collapse" id="navbarsMagick" style=""> 40 <ul class="navbar-nav mr-auto"> 41 <li class="nav-item "> 42 <a class="nav-link" href="api/quantize.html">Home <span class="sr-only">(current)</span></a> 43 </li> 44 <li class="nav-item "> 45 <a class="nav-link" href="../www/download.html">Download</a> 46 </li> 47 <li class="nav-item "> 48 <a class="nav-link" href="../www/command-line-tools.html">Tools</a> 49 </li> 50 <li class="nav-item "> 51 <a class="nav-link" href="../www/command-line-processing.html">Command-line</a> 52 </li> 53 <li class="nav-item "> 54 <a class="nav-link" href="../www/resources.html">Resources</a> 55 </li> 56 <li class="nav-item "> 57 <a class="nav-link" href="../www/develop.html">Develop</a> 58 </li> 59 <li class="nav-item"> 60 <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a> 61 </li> 62 </ul> 63 <form class="form-inline my-2 my-lg-0" action="https://imagemagick.org/script/search.php"> 64 <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search"> 65 <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button> 66 </form> 67 </div> 68 </nav> 69 <div class="container"> 70 <script async="async" src="https://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" 71 style="display:block" 72 data-ad-client="ca-pub-3129977114552745" 73 data-ad-slot="6345125851" 74 data-ad-format="auto"></ins> 75 <script> 76 (adsbygoogle = window.adsbygoogle || []).push({}); 77 </script> 78 79 </div> 80 </header> 81 <main class="container"> 82 <div class="magick-template"> 83<div class="magick-header"> 84<p class="text-center"><a href="perl-magick.html#installation">Installation</a> • <a href="perl-magick.html#overview">Overview</a> • <a href="perl-magick.html#example">Example Script</a> • <a href="perl-magick.html#read">Read or Write an Image</a> • <a href="perl-magick.html#manipulate">Manipulate an Image</a> • <a href="perl-magick.html#set-attribute">Set an Image Attribute</a> • <a href="perl-magick.html#get-attribute">Get an Image Attribute</a> • <a href="perl-magick.html#compare">Compare an Image to its Reconstruction</a> • <a href="perl-magick.html#montage">Create an Image Montage</a> • <a href="perl-magick.html#blobs">Working with Blobs</a> • <a href="perl-magick.html#direct-access">Direct-access to Image Pixels</a> • <a href="perl-magick.html#miscellaneous">Miscellaneous Methods</a> • <a href="perl-magick.html#exceptions">Handling Exceptions</a>• <a href="perl-magick.html#constants">Constant</a> </p> 85 86<a class="anchor" id="introduction"></a> 87<p class="lead magick-description"><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> 88 89<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="https://imagemagick.org/download/perl">MagickStudio</a>, or use <a href="http://git.imagemagick.org/repos/ImageMagick/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> 90 91<p>You can try PerlMagick from your Web browser at the <a href="../MagickStudio/scripts/MagickStudio.cgi">ImageMagick Studio</a>. Or, you can see <a href="examples.html">examples</a> of select PerlMagick functions.</p> 92 93<h2><a class="anchor" id="installation"></a>Installation</h2> 94 95<p><b>UNIX</b></p> 96 97<p>Is PerlMagick available from your system RPM repository? For example, on our CentOS system, we install PerlMagick thusly:</p> 98 99<pre class="highlight"><code>yum install ImageMagick-perl 100</code></pre> 101 102<p>If not, you must install PerlMagick from the ImageMagick source distribution. Download the latest <a href="https://imagemagick.org/download/ImageMagick.tar.gz">source</a> release.</p> 103 104<p>Unpack the distribution with this command:</p> 105 106<pre class="highlight"><code>tar xvzf ImageMagick.tar.gz 107</code></pre> 108 109<p>Next configure and compile ImageMagick:</p> 110 111<pre class="highlight"><span class="crtprompt">$ </span><span class='crtin'>cd ImageMagick-7.0.8</span><span class='crtout'></span><span class="crtprompt">$ </span><span class='crtin'>./configure -with-perl</span><span class='crtout'></span><span class="crtprompt">$ </span><span class='crtin'>make</span></pre> 112<p>If ImageMagick / PerlMagick configured and compiled without complaint, you are ready to install it on your system. Administrator privileges are required to install. To install, type</p> 113 114<pre class="highlight"><code>sudo make install 115</code></pre> 116 117<p>You may need to configure the dynamic linker run-time bindings:</p> 118 119<pre class="highlight"><code>sudo ldconfig /usr/local/lib 120</code></pre> 121 122 123<p>Finally, verify the PerlMagick install worked properly, type</p> 124 125<pre class="highlight"><code>perl -MImage::Magick -le 'print Image::Magick->QuantumDepth' 126</code></pre> 127 128<p>Congratulations, you have a working ImageMagick distribution and you are ready to use PerlMagick to <a href="../Usage/">convert, compose, or edit</a> your images.</p> 129 130<p><b>Windows XP / Windows 2000</b></p> 131 132<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 <code>nmake</code> from the Visual C++ or J++ development environment. Copy <code>\bin\IMagick.dll</code> and <code>\bin\X11.dll</code> to a directory in your dynamic load path such as <code>c:\perl\site\5.00502</code>.</p> 133 134<p>Next, type</p> 135 136<pre class="highlight"><code>cd PerlMagick 137perl Makefile.nt 138nmake 139nmake install 140</code></pre> 141 142<p>See the <a href="http://www.dylanbeattie.net/magick/">PerlMagick Windows HowTo</a> page for further installation instructions.</p> 143 144<p><b>Running the Regression Tests</b></p> 145 146<p>To verify a correct installation, type</p> 147 148<pre class="highlight"><code>make test 149</code></pre> 150 151<p>Use <code>nmake test</code> under Windows. There are a few demonstration scripts available to exercise many of the functions PerlMagick can perform. Type</p> 152 153<pre class="highlight"><code>cd demo 154make 155</code></pre> 156 157<p>You are now ready to utilize the PerlMagick methods from within your Perl scripts.</p> 158 159<h2><a class="anchor" id="overview"></a>Overview</h2> 160 161<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> 162 163<pre class="highlight"><code>use Image::Magick; 164 165$image = Image::Magick->new; 166</code></pre> 167 168<p>PerlMagick is <var>quantum</var> aware. You can request a specific quantum depth when you instantiate an image object:</p> 169 170<pre class="highlight"><code>use Image::Magick::Q16; 171 172$image = Image::Magick::Q16->new; 173</code></pre> 174 175<p>The new() method takes the same parameters as <a href="perl-magick.html#set-attribute">SetAttribute</a> . For example,</p> 176 177<pre class="highlight"><code>$image = Image::Magick->new(size=>'384x256'); 178</code></pre> 179 180<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="perl-magick.html#read">Read or Write an Image</a>. See <a href="perl-magick.html#set-attribute">Set an Image Attribute</a> for methods that affect the way an image is read or written. Refer to <a href="perl-magick.html#manipulate">Manipulate an Image</a> for a list of methods to transform an image. <a href="perl-magick.html#get-attribute">Get an Image Attribute</a> describes how to retrieve an attribute for an image. Refer to <a href="perl-magick.html#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="perl-magick.html#misc">Miscellaneous Methods</a> for a list of these methods.</p> 181 182<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 <code>undef</code>:</p> 183 184<pre class="highlight"><code>undef $image; 185</code></pre> 186 187<p>To delete all the images but retain the <code>Image::Magick</code> object use</p> 188 189<pre class="highlight"><code>@$image = (); 190</code></pre> 191 192<p>and finally, to delete a single image from a multi-image sequence, use</p> 193 194<pre class="highlight"><code>undef $image->[$x]; 195</code></pre> 196 197<p>The next section illustrates how to use various PerlMagick methods to manipulate an image sequence.</p> 198 199<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> 200 201<pre class="highlight"><code>$ENV{PATH}' . "='/../bin:/usr/bin:/usr/local/bin'; 202</code></pre> 203 204<h2><a class="anchor" id="example"></a>Example Script</h2> 205 206<p>Here is an example script to get you started:</p> 207 208<pre class="highlight"><code>#!/usr/local/bin/perl 209use Image::Magick;<br /> 210my($image, $x);<br /> 211$image = Image::Magick->new; 212$x = $image->Read('girl.png', 'logo.png', 'rose.png'); 213warn "$x" if "$x";<br /> 214$x = $image->Crop(geometry=>'100x100+100+100'); 215warn "$x" if "$x";<br /> 216$x = $image->Write('x.png'); 217warn "$x" if "$x"; 218</code></pre> 219 220<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> 221 222<pre class="pre-scrollable"><code>#!/usr/local/bin/perl 223use Image::Magick;<br /> 224my($image, $p, $q);<br /> 225$image = new Image::Magick; 226$image->Read('x1.png'); 227$image->Read('j*.jpg'); 228$image->Read('k.miff[1, 5, 3]'); 229$image->Contrast(); 230for ($x = 0; $image->[$x]; $x++) 231{ 232 $image->[$x]->Frame('100x200') if $image->[$x]->Get('magick') eq 'GIF'; 233 undef $image->[$x] if $image->[$x]->Get('columns') < 100; 234} 235$p = $image->[1]; 236$p->Draw(stroke=>'red', primitive=>'rectangle', points=>20,20 100,100'); 237$q = $p->Montage(); 238undef $image; 239$q->Write('x.miff'); 240</code></pre> 241 242<p>Suppose you want to start out with a 100 by 100 pixel white canvas with a red pixel in the center. Try</p> 243 244<pre class="highlight"><code>$image = Image::Magick->new; 245$image->Set(size=>'100x100'); 246$image->ReadImage('canvas:white'); 247$image->Set('pixel[49,49]'=>'red'); 248</code></pre> 249 250<p>Here we reduce the intensity of the red component at (1,1) by half:</p> 251 252<pre class="highlight"><code>@pixels = $image->GetPixel(x=>1,y=>1); 253$pixels[0]*=0.5; 254$image->SetPixel(x=>1,y=>1,color=>\@pixels); 255</code></pre> 256 257<p>Or suppose you want to convert your color image to grayscale:</p> 258 259<pre class="highlight"><code>$image->Quantize(colorspace=>'gray'); 260</code></pre> 261 262<p>Let's annotate an image with a Taipai TrueType font:</p> 263 264<pre class="highlight"><code>$text = 'Works like magick!'; 265$image->Annotate(font=>'kai.ttf', pointsize=>40, fill=>'green', text=>$text); 266</code></pre> 267 268<p>Perhaps you want to extract all the pixel intensities from an image and write them to STDOUT:</p> 269 270<pre class="highlight"><code>@pixels = $image->GetPixels(map=>'I', height=>$height, width=>$width, normalize=>true); 271binmode STDOUT; 272print pack('B*',join('',@pixels)); 273</code></pre> 274 275<p>Other clever things you can do with a PerlMagick objects include</p> 276 277<pre class="highlight"><code>$i = $#$p"+1"; # return the number of images associated with object p 278push(@$q, @$p); # push the images from object p onto object q 279@$p = (); # delete the images but not the object p 280$p->Convolve([1, 2, 1, 2, 4, 2, 1, 2, 1]); # 3x3 Gaussian kernel 281</code></pre> 282 283 <h2><a class="anchor" id="read"></a>Read or Write an Image</h2> 284 285<p>Use the methods listed below to either read, write, or display an image or image sequence:</p> 286 287<table class="table table-sm table-striped"> 288<caption>Read or Write Methods</caption> 289<colgroup> 290 <col width="20%" /> 291 <col width="20%" /> 292 <col width="20%" /> 293 <col width="40%" /> 294</colgroup> 295<tbody> 296 297 <tr> 298 <th>Method</th> 299 <th>Parameters</th> 300 <th>Return Value</th> 301 <th>Description</th> 302 </tr> 303 304 <tr> 305 <td>Read</td> 306 <td>one or more filenames</td> 307 <td>the number of images read</td> 308 <td>read an image or image sequence</td> 309 </tr> 310 311 <tr> 312 <td>Write</td> 313 <td>filename</td> 314 <td>the number of images written</td> 315 <td>write an image or image sequence</td> 316 </tr> 317 318 <tr> 319 <td>Display</td> 320 <td>server name</td> 321 <td>the number of images displayed</td> 322 <td>display the image or image sequence to an X server</td> 323 </tr> 324 325 <tr> 326 <td>Animate</td> 327 <td>server name</td> 328 <td>the number of images animated</td> 329 <td>animate image sequence to an X server</td> 330 </tr> 331</tbody> 332</table> 333 334<p>For convenience, methods Write(), Display(), and Animate() can take any parameter that <a href="perl-magick.html#set-attribute">SetAttribute</a> knows about. For example,</p> 335 336<pre class="highlight"><code>$image->Write(filename=>'image.png', compression=>'None'); 337</code></pre> 338 339<p>Use <code>-</code> as the filename to method Read() to read from standard in or to method Write() to write to standard out:</p> 340 341<pre class="highlight"><code>binmode STDOUT; 342$image->Write('png:-'); 343</code></pre> 344 345<p>To read an image in the GIF format from a PERL filehandle, use:</p> 346 347<pre class="highlight"><code>$image = Image::Magick->new; 348open(IMAGE, 'image.gif'); 349$image->Read(file=>\*IMAGE); 350close(IMAGE); 351</code></pre> 352 353<p>To write an image in the PNG format to a PERL filehandle, use:</p> 354 355<pre class="highlight"><code>$filename = "image.png"; 356open(IMAGE, ">$filename"); 357$image->Write(file=>\*IMAGE, filename=>$filename); 358close(IMAGE); 359</code></pre> 360 361<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> 362 363<p>If <code>%0Nd, %0No, or %0Nx</code> 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> 364 365<pre class="highlight"><code>image%03d.miff 366</code></pre> 367 368<p>converts files image000.miff, image001.miff, etc.</p> 369 370<p>You can optionally add <i>Image</i> to any method name. For example, ReadImage() is an alias for method Read().</p> 371 372<h2><a class="anchor" id="manipulate"></a>Manipulate an Image</h2> 373 374<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="examples.html">examples</a> of select PerlMagick methods. Here is an example call to an image manipulation method:</p> 375 376<pre class="highlight"><code>$image->Crop(geometry=>'100x100+10+20'); 377$image->[$x]->Frame("100x200"); 378</code></pre> 379 380<p>And here is a list of other image manipulation methods you can call:</p> 381 382<table class="table table-sm table-striped"> 383<caption>Image Manipulation Methods</caption> 384<tbody> 385 <tr> 386 <th>Method</th> 387 <th style="width: 40%">Parameters</th> 388 <th style="width: 40%">Description</th> 389 </tr> 390 391 <tr> 392 <td>AdaptiveBlur</td> 393 <td>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, Alpha, Red, RGB, Yellow}</td> 394 <td>adaptively blur the image with a Gaussian operator of the given radius and standard deviation (sigma). Decrease the effect near edges.</td> 395 </tr> 396 397 <tr> 398 <td>AdaptiveResize</td> 399 <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>, blur=><i>double</i></td> 400 <td>adaptively resize image using data dependant triangulation. Specify <code>blur</code> > 1 for blurry or < 1 for sharp</td> 401 </tr> 402 403 <tr> 404 <td>AdaptiveSharpen</td> 405 <td>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, Alpha, Red, RGB, Yellow}</td> 406 <td>adaptively sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma). Increase the effect near edges.</td> 407 </tr> 408 409 <tr> 410 <td>AdaptiveThreshold</td> 411 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, bias=><i>double</i></td> 412 <td>local adaptive thresholding.</td> 413 </tr> 414 415 <tr> 416 <td>AddNoise</td> 417 <td>noise=>{Uniform, Gaussian, Multiplicative, Impulse, Laplacian, Poisson}, attenuate=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 418 <td>add noise to an image</td> 419 </tr> 420 421 <tr> 422 <td>AffineTransform</td> 423 <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>, interpolate={Average, Bicubic, Bilinear, Filter, Integer, Mesh, NearestNeighbor}, background=><i><a href="color.html">color name</a></i></td> 424 <td>affine transform image</td> 425 </tr> 426 427 <tr> 428 <td>Affinity</td> 429 <td>image=><i>image-handle</i>, method=>{None, FloydSteinberg, Riemersma}</td> 430 <td>choose a particular set of colors from this image</td> 431 </tr> 432 433 <tr> 434 <td>Annotate</td> 435 <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="color.html">color name</a></i>, strokewidth=><i>integer</i>, fill=><i><a href="color.html">color name</a></i>, undercolor=><i><a href="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> 436 <td>annotate an image with text. See <a href="perl-magick.html#misc">QueryFontMetrics</a> to get font metrics without rendering any text.</td> 437 </tr> 438 439 <tr> 440 <td>AutoGamma</td> 441 <td>channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 442 <td>automagically adjust gamma level of image</td> 443 </tr> 444 445 <tr> 446 <td>AutoLevel</td> 447 <td>channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 448 <td>automagically adjust color levels of image</td> 449 </tr> 450 451 <tr> 452 <td>AutoOrient</td> 453 <td><br /></td> 454 <td>adjusts an image so that its orientation is suitable for viewing (i.e. top-left orientation)</td> 455 </tr> 456 457 <tr> 458 <td>AutoThreshold</td> 459 <td>method=>{Kapur, OTSU, Triangle}</td> 460 <td>automatically perform image thresholding</td> 461 </tr> 462 463 <tr> 464 <td>BlackThreshold</td> 465 <td>threshold=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 466 <td>force all pixels below the threshold intensity into black</td> 467 </tr> 468 469 <tr> 470 <td>BlueShift</td> 471 <td>factor=><i>double</i>,</td> 472 <td>simulate a scene at nighttime in the moonlight. Start with a factor of 1.5.</td> 473 </tr> 474 475 <tr> 476 <td>Blur</td> 477 <td>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, Alpha, Red, RGB, Yellow}</td> 478 <td>reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td> 479 </tr> 480 481 <tr> 482 <td>Border</td> 483 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, bordercolor=><i><a href="color.html">color name</a></i>, compose=>{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyAlpha, 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> 484 <td>surround the image with a border of color</td> 485 </tr> 486 487 <tr> 488 <td>CannyEdge</td> 489 <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, 'lower-percent'=><i>double</i>, 'upper-percent'=><i>double</i></td> 490 <td>use a multi-stage algorithm to detect a wide range of edges in the image (e.g. CannyEdge('0x1+10%+40%')).</td> 491 </tr> 492 493 <tr> 494 <td>Charcoal</td> 495 <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i></td> 496 <td>simulate a charcoal drawing</td> 497 </tr> 498 499 <tr> 500 <td>Chop</td> 501 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> 502 <td>chop an image</td> 503 </tr> 504 505 <tr> 506 <td>CLAHE</td> 507 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, number-bins=><i>integer</i>, clip-limit=><i>double</i></td> 508 <td>contrast limited adaptive histogram equalization. <var>width</var>, <var>height</var> divides the image into tiles. <var>number-bins</var> is the number of histogram bins per tile (min 2, max 256). <var>clip-limit</var> is the contrast limit for localised changes in contrast. A clip-limit of 2 to 3 is a good starting place.</td> 509 </tr> 510 511 <tr> 512 <td>Clamp</td> 513 <td>channel=>{Red, RGB, All, etc.}</td> 514 <td>set each pixel whose value is below zero to zero and any the pixel whose value is above the quantum range to the quantum range (e.g. 65535) otherwise the pixel value remains unchanged.</td> 515 </tr> 516 517 <tr> 518 <td>Clip</td> 519 <td>id=><i>name</i>, inside=><i>{true, false}</i>,</td> 520 <td>apply along a named path from the 8BIM profile.</td> 521 </tr> 522 523 <tr> 524 <td>ClipMask</td> 525 <td>mask=><i>image-handle</i></td> 526 <td>clip image as defined by the image mask</td> 527 </tr> 528 529 <tr> 530 <td>Clut</td> 531 <td>image=><i>image-handle</i>, interpolate={Average, Bicubic, Bilinear, Filter, Integer, Mesh, NearestNeighbor}, channel=>{Red, RGB, All, etc.}</td> 532 <td>apply a color lookup table to an image sequence</td> 533 </tr> 534 535 <tr> 536 <td>Coalesce</td> 537 <td><br /></td> 538 <td>merge a sequence of images</td> 539 </tr> 540 541 <tr> 542 <td>Color</td> 543 <td>color=><i><a href="color.html">color name</a></i></td> 544 <td>set the entire image to this color.</td> 545 </tr> 546 547 <tr> 548 <td>ColorDecisionList</td> 549 <td>filename=><i>string</i>,</td> 550 <td>color correct with a color decision list.</td> 551 </tr> 552 553 <tr> 554 <td>Colorize</td> 555 <td>fill=><i><a href="color.html">color name</a></i>, blend=><i>string</i></td> 556 <td>colorize the image with the fill color</td> 557 </tr> 558 559 <tr> 560 <td>ColorMatrix</td> 561 <td>matrix=><i>array of float values</i></td> 562 <td>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> 563 </tr> 564 565 <tr> 566 <td>Colorspace</td> 567 <td>colorspace=>{RGB, Gray, Transparent, OHTA, XYZ, YCbCr, YCC, YIQ, YPbPr, YUV, CMYK}</td> 568 <td> set the image colorspace</td> 569 </tr> 570 571 <tr> 572 <td>Comment</td> 573 <td>string</td> 574 <td>add a comment to your image</td> 575 </tr> 576 577 <tr> 578 <td>CompareLayers</td> 579 <td>method=>{any, clear, overlay}</td> 580 <td>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> 581 </tr> 582 583 <tr> 584 <td>Composite</td> 585 <td>image=><i>image-handle</i>, compose=>{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyAlpha, 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="color.html">color name</a></i>, blend=><i>geometry</i>, interpolate=>{undefined, average, bicubic, bilinear, filter, integer, mesh, nearest-neighbor, spline}, clip-to-self=>{True, False}</td> 586 <td>composite one image onto another. Use the rotate parameter in concert with the tile parameter.</td> 587 </tr> 588 589 <tr> 590 <td>ConnectedComponents</td> 591 <td>connectivity=><i>integer</i>,</td> 592 <td>connected-components uniquely labeled, choose from 4 or 8 way connectivity.</td> 593 </tr> 594 595 <tr> 596 <td>Contrast</td> 597 <td>sharpen=>{True, False}</td> 598 <td>enhance or reduce the image contrast</td> 599 </tr> 600 601 <tr> 602 <td>ContrastStretch</td> 603 <td>levels=><i>string</i>, 'black-point'=><i>double</i>, 'white-point'=><i>double</i>, channel=>{Red, RGB, All, etc.}</td> 604 <td>improve the contrast in an image by `stretching' the range of intensity values</td> 605 </tr> 606 607 <tr> 608 <td>Convolve</td> 609 <td>coefficients=><i>array of float values</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, bias=><i>double</i></td> 610 <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> 611 </tr> 612 613 <tr> 614 <td>CopyPixels</td> 615 <td>image=><i>image-handle</i>, geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, offset=><i>geometry</i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, dx=><i>integer</i>, dy=><i>integer</i></td> 616 <td>copy pixels from the image as defined by the <code>width</code>x<code>height</code>+<code>x</code>+<code>y</code> to image at offset +<code>dx</code>,+<code>dy</code>.</td> 617 </tr> 618 619 <tr> 620 <td>Crop</td> 621 <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>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> 622 <td>crop an image</td> 623 </tr> 624 625 <tr> 626 <td>CycleColormap</td> 627 <td>amount=><i>integer</i></td> 628 <td>displace image colormap by amount</td> 629 </tr> 630 631 <tr> 632 <td>Decipher</td> 633 <td>passphrase=><i>string</i></td> 634 <td>convert cipher pixels to plain pixels</td> 635 </tr> 636 637 <tr> 638 <td>Deconstruct</td> 639 <td><br /></td> 640 <td>break down an image sequence into constituent parts</td> 641 </tr> 642 643 <tr> 644 <td>Deskew</td> 645 <td>geometry=><i>string</i>,threshold=><i>double</i></td> 646 <td>straighten the image</td> 647 </tr> 648 649 <tr> 650 <td>Despeckle</td> 651 <td> </td> 652 <td>reduce the speckles within an image</td> 653 </tr> 654 655 <tr> 656 <td>Difference</td> 657 <td>image=><i>image-handle</i></td> 658 <td>compute the difference metrics between two images </td> 659 </tr> 660 661 <tr> 662 <td>Distort</td> 663 <td>points=><i>array of float values</i>, method=>{Affine, AffineProjection, ScaleRotateTranslate, SRT, Perspective, PerspectiveProjection, BilinearForward, BilinearReverse, Polynomial, Arc, Polar, DePolar, Barrel, BarrelInverse, Shepards, Resize}, 'virtual-pixel'=>{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}, 'best-fit'=>{True, False}</td> 664 <td>distort image</td> 665 </tr> 666 667 <tr> 668 <td>Draw</td> 669 <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="color.html">color name</a></i>, fill=><i><a href="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="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> 670 <td>annotate an image with one or more graphic primitives.</td> 671 </tr> 672 673 <tr> 674 <td>Encipher</td> 675 <td>passphrase=><i>string</i></td> 676 <td>convert plain pixels to cipher pixels</td> 677 </tr> 678 679 <tr> 680 <td>Edge</td> 681 <td>radius=><i>double</i></td> 682 <td>enhance edges within the image with a convolution filter of the given radius.</td> 683 </tr> 684 685 <tr> 686 <td>Emboss</td> 687 <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i></td> 688 <td>emboss the image with a convolution filter of the given radius and standard deviation (sigma).</td> 689 </tr> 690 691 <tr> 692 <td>Enhance</td> 693 <td><br /></td> 694 <td>apply a digital filter to enhance a noisy image</td> 695 </tr> 696 697 <tr> 698 <td>Equalize</td> 699 <td>channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}<br /></td> 700 <td>perform histogram equalization to the image</td> 701 </tr> 702 703 <tr> 704 <td>Extent</td> 705 <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>, background=><i><a href="color.html">color name</a></i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> 706 <td>set the image size</td> 707 </tr> 708 709 <tr> 710 <td>Evaluate</td> 711 <td>value=><i>double</i>, operator=><i>{Add, And, Divide, LeftShift, Max, Min, Multiply, Or, Rightshift, RMS, Subtract, Xor}</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow} </td> 712 <td>apply an arithmetic, relational, or logical expression to the image</td> 713 </tr> 714 715 <tr> 716 <td>Filter</td> 717 <td>kernel=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, bias=><i>double</i></td> 718 <td>apply a convolution kernel to the image.</td> 719 </tr> 720 721 <tr> 722 <td>Flip</td> 723 <td><br /></td> 724 <td>reflect the image scanlines in the vertical direction</td> 725 </tr> 726 727 <tr> 728 <td>Flop</td> 729 <td><br /></td> 730 <td>reflect the image scanlines in the horizontal direction</td> 731 </tr> 732 733 <tr> 734 <td>FloodfillPaint</td> 735 <td>geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, x=><i>integer</i>, y=><i>integer</i> , fill=><i><a href="color.html">color name</a></i>, bordercolor=><i><a href="color.html">color name</a></i>, fuzz=><i>double</i>, invert=>{True, False}</td> 736 <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> 737 </tr> 738 739 <tr> 740 <td>ForwardFourierTransform</td> 741 <td>magnitude=>{True, False}</td> 742 <td>implements the forward discrete Fourier transform (DFT)</td> 743 </tr> 744 745 <tr> 746 <td>Frame</td> 747 <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="color.html">color name</a></i>, compose=>{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyAlpha, 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> 748 <td>surround the image with an ornamental border</td> 749 </tr> 750 751 <tr> 752 <td>Function</td> 753 <td>parameters=><i>array of float values</i>, function=>{Sin}, 'virtual-pixel'=>{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td> 754 <td>apply a function to the image</td> 755 </tr> 756 757 <tr> 758 <td>Gamma</td> 759 <td>gamma=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 760 <td>gamma correct the image</td> 761 </tr> 762 763 <tr> 764 <td>GaussianBlur</td> 765 <td>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, Alpha, Red, RGB, Yellow}</td> 766 <td>reduce image noise and reduce detail levels with a Gaussian operator of the given radius and standard deviation (sigma).</td> 767 </tr> 768 769 <tr> 770 <td>GetPixel</td> 771 <td>geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, normalize=>{true, false}, x=><i>integer</i>, y=><i>integer</i></td> 772 <td>get a single pixel. By default normalized pixel values are returned.</td> 773 </tr> 774 775 <tr> 776 <td>GetPixels</td> 777 <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> 778 <td>get image pixels as defined by the map (e.g. "RGB", "RGBA", etc.). By default non-normalized pixel values are returned.</td> 779 </tr> 780 781 <tr> 782 <td>Grayscale</td> 783 <td>channel=>{Average, Brightness, Lightness, Rec601Luma, Rec601Luminance, Rec709Luma, Rec709Luminance, RMS}</td> 784 <td>convert image to grayscale</td> 785 </tr> 786 787 <tr> 788 <td>HaldClut</td> 789 <td>image=><i>image-handle</i>, channel=>{Red, RGB, All, etc.}</td> 790 <td>apply a Hald color lookup table to an image sequence</td> 791 </tr> 792 793 <tr> 794 <td>HoughLine</td> 795 <td>geometry=><i>geometry</i>, width=><i>double</i>, height=><i>double</i>, threshold=><i>double</i></td> 796 <td>identify lines in the image (e.g. HoughLine('9x9+195')).</td> 797 </tr> 798 799 <tr> 800 <td>Identify</td> 801 <td>file=><i>file</i>, features=><i>distance</i>, unique=>{True, False}</td> 802 <td>identify the attributes of an image</td> 803 </tr> 804 805 <tr> 806 <td>Implode</td> 807 <td>amount=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td> 808 <td>implode image pixels about the center</td> 809 </tr> 810 811 <tr> 812 <td>InverseDiscreteFourierTransform</td> 813 <td>magnitude=>{True, False}</td> 814 <td>implements the inverse discrete Fourier transform (DFT)</td> 815 </tr> 816 817 <tr> 818 <td>Kuwahara</td> 819 <td>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, Alpha, Red, RGB, Yellow}</td> 820 <td>edge preserving noise reduction filter</td> 821 </tr> 822 823 <tr> 824 <td>Label</td> 825 <td>string</td> 826 <td>assign a label to an image</td> 827 </tr> 828 829 <tr> 830 <td>Layers</td> 831 <td>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, CopyAlpha, 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> 832 <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> 833 </tr> 834 835 <tr> 836 <td>Level</td> 837 <td>levels=><i>string</i>, 'black-point'=><i>double</i>, 'gamma'=><i>double</i>, 'white-point'=><i>double</i>, channel=>{Red, RGB, All, etc.}</td> 838 <td>adjust the level of image contrast</td> 839 </tr> 840 841 <tr> 842 <td>LevelColors</td> 843 <td>invert=>>{True, False}, 'black-point'=><i>string</i>, 'white-point'=><i>string</i>, channel=>{Red, RGB, All, etc.}</td> 844 <td>level image with the given colors</td> 845 </tr> 846 847 <tr> 848 <td>LinearStretch</td> 849 <td>levels=><i>string</i>, 'black-point'=><i>double</i>, 'white-point'=><i>double</i></td> 850 <td>linear with saturation stretch</td> 851 </tr> 852 853 <tr> 854 <td>LiquidResize</td> 855 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, delta-x=><i>double</i>, rigidity=><i>double</i></td> 856 <td>rescale image with seam-carving.</td> 857 </tr> 858 859 <tr> 860 <td>Magnify</td> 861 <td><br /></td> 862 <td>double the size of the image with pixel art scaling</td> 863 </tr> 864 865 <tr> 866 <td>Mask</td> 867 <td>mask=><i>image-handle</i></td> 868 <td>composite image pixels as defined by the mask</td> 869 </tr> 870 871 <tr> 872 <td>MatteFloodfill</td> 873 <td>geometry=><i>geometry</i>, x=><i>integer</i>, y=><i>integer</i> , matte=><i>integer</i>, bordercolor=><i><a href="color.html">color name</a></i>, fuzz=><i>double</i>, invert=>{True, False}</td> 874 <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> 875 </tr> 876 877 <tr> 878 <td>MeanShift</td> 879 <td>geometry=><i>geometry</i>, width=><i>double</i>, height=><i>double</i>, distance=><i>double</i></td> 880 <td>delineate arbitrarily shaped clusters in the image (e.g. MeanShift('7x7+10%')).</td> 881 </tr> 882 883 <tr> 884 <td>MedianFilter</td> 885 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 886 <td>replace each pixel with the median intensity pixel of a neighborhood.</td> 887 </tr> 888 889 <tr> 890 <td>Minify</td> 891 <td><br /></td> 892 <td>half the size of an image</td> 893 </tr> 894 895 <tr> 896 <td>Mode</td> 897 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 898 <td>make each pixel the <var>predominant color</var> of the neighborhood.</td> 899 </tr> 900 901 <tr> 902 <td>Modulate</td> 903 <td>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> 904 <td>vary the brightness, saturation, and hue of an image by the specified percentage</td> 905 </tr> 906 907 <tr> 908 <td>Morphology</td> 909 <td>kernel=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, iterations=><i>integer</i></td> 910 <td>apply a morphology method to the image.</td> 911 </tr> 912 913 <tr> 914 <td>MotionBlur</td> 915 <td>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, Alpha, Red, RGB, Yellow}</td> 916 <td>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> 917 </tr> 918 919 <tr> 920 <td>Negate</td> 921 <td>gray=>{True, False}, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 922 <td>replace each pixel with its complementary color (white becomes black, yellow becomes blue, etc.)</td> 923 </tr> 924 925 <tr> 926 <td>Normalize</td> 927 <td>channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}<br /></td> 928 <td>transform image to span the full range of color values</td> 929 </tr> 930 931 <tr> 932 <td>OilPaint</td> 933 <td>radius=><i>integer</i></td> 934 <td>simulate an oil painting</td> 935 </tr> 936 937 <tr> 938 <td>Opaque</td> 939 <td>color=><i><a href="color.html">color name</a></i>, 940fill=><i><a href="color.html">color name</a></i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, invert=>{True, False}</td> 941 <td>change this color to the fill color within the image</td> 942 </tr> 943 944 <tr> 945 <td>OrderedDither</td> 946 <td>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, Alpha, Red, RGB, Yellow}</td> 947 <td>order dither image</td> 948 </tr> 949 950 <tr> 951 <td>Perceptible</td> 952 <td>epsilon=><i>double</i>, channel=>{Red, RGB, All, etc.}</td> 953 <td>set each pixel whose value is less than |<var>epsilon</var>| to <var>-epsilon</var> or <var>epsilon</var> (whichever is closer) otherwise the pixel value remains unchanged..</td> 954 </tr> 955 956 <tr> 957 <td>Polaroid</td> 958 <td>caption=><i>string</i>, angle=><i>double</i>, pointsize=><i>double</i>, font=><i>string</i>, stroke=> <i><a href="color.html">color name</a></i>, strokewidth=><i>integer</i>, fill=><i><a href="color.html">color name</a></i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}, background=><i><a href="color.html">color name</a></i></td> 959 <td>simulate a Polaroid picture.</td> 960 </tr> 961 962 <tr> 963 <td>Posterize</td> 964 <td>levels=><i>integer</i>, dither=>{True, False}</td> 965 <td>reduce the image to a limited number of color level</td> 966 </tr> 967 968 <tr> 969 <td>Profile</td> 970 <td>name=><i>string</i>, profile=><i>blob</i>, rendering-intent=>{Undefined, Saturation, Perceptual, Absolute, Relative}, black-point-compensation=>{True, False}</td> 971 <td>add or remove ICC or IPTC image profile; name is formal name (e.g. ICC or filename; set profile to <code>''</code> to remove profile</td> 972 </tr> 973 974 <tr> 975 <td>Quantize</td> 976 <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}, dither-method=>{Riemersma, Floyd-Steinberg}, measure_error=>{True, False}, global_colormap=>{True, False}, transparent-color=><i>color</i></td> 977 <td>preferred number of colors in the image</td> 978 </tr> 979 980 <tr> 981 <td>Raise</td> 982 <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> 983 <td>lighten or darken image edges to create a 3-D effect</td> 984 </tr> 985 986 <tr> 987 <td>RangeThreshold</td> 988 <td>geometry=><i>geometry</i>, 'low-black'=><i>double</i>, 'low-white'=><i>double</i>, 'high-white'=><i>double</i>, 'high-black'=><i>double</i></td> 989 <td>combine soft and hard image thresholding.</td> 990 </tr> 991 992 <tr> 993 <td>ReduceNoise</td> 994 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 995 <td>reduce noise in the image with a noise peak elimination filter</td> 996 </tr> 997 998 <tr> 999 <td>Remap</td> 1000 <td>image=><i>image-handle</i>, dither=>{true, false}, dither-method=>{Riemersma, Floyd-Steinberg}</td> 1001 <td>replace the colors of an image with the closest color from a reference image.</td> 1002 </tr> 1003 1004 <tr> 1005 <td>Resample</td> 1006 <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> 1007 <td>resample image to desired resolution. Specify <code>blur</code> > 1 for blurry or < 1 for sharp</td> 1008 </tr> 1009 1010 <tr> 1011 <td>Resize</td> 1012 <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>, blur=><i>double</i></td> 1013 <td>scale image to desired size. Specify <code>blur</code> > 1 for blurry or < 1 for sharp</td> 1014 </tr> 1015 1016 <tr> 1017 <td>Roll</td> 1018 <td>geometry=><i>geometry</i>, x=><i>integer</i>, y=><i>integer</i></td> 1019 <td>roll an image vertically or horizontally</td> 1020 </tr> 1021 1022 <tr> 1023 <td>Rotate</td> 1024 <td>degrees=><i>double</i>, background=><i><a href="color.html">color name</a></i></td> 1025 <td>rotate an image</td> 1026 </tr> 1027 1028 <tr> 1029 <td>RotationalBlur</td> 1030 <td>geometry=><i>geometry</i>, angle=><i>double</i>, bias=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 1031 <td>radial blur the image.</td> 1032 </tr> 1033 1034 <tr> 1035 <td>Sample</td> 1036 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> 1037 <td>scale image with pixel sampling.</td> 1038 </tr> 1039 1040 <tr> 1041 <td>Scale</td> 1042 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> 1043 <td>scale image to desired size</td> 1044 </tr> 1045 1046 <tr> 1047 <td>Segment</td> 1048 <td>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> 1049 <td>segment an image by analyzing the histograms of the color components and identifying units that are homogeneous</td> 1050 </tr> 1051 1052 <tr> 1053 <td>SelectiveBlur</td> 1054 <td>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, Alpha, Red, RGB, Yellow}</td> 1055 <td>selectively blur pixels within a contrast threshold.</td> 1056 </tr> 1057 <tr> 1058 <td>Separate</td> 1059 <td>channel=>{Red, RGB, All, etc.}</td> 1060 <td>separate a channel from the image into a grayscale image</td> 1061 </tr> 1062 1063 <tr> 1064 <td>Shade</td> 1065 <td>geometry=><i>geometry</i>, azimuth=><i>double</i>, elevation=><i>double</i>, gray=>{true, false}</td> 1066 <td>shade the image using a distant light source</td> 1067 </tr> 1068 1069 <tr> 1070 <td>SetPixel</td> 1071 <td>geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, 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> 1072 <td>set the value a single pixel. Normalized pixel values are expected.</td> 1073 </tr> 1074 1075 <tr> 1076 <td>SetPixels</td> 1077 <td>geometry=><i>geometry</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, color=><i>array of float values</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i>, color=><i>array of float values</i></td> 1078 <td>set the value of one or more pixels. Normalized pixel values are expected.</td> 1079 </tr> 1080 1081 <tr> 1082 <td>Shadow</td> 1083 <td>geometry=><i>geometry</i>, opacity=><i>double</i>, sigma=><i>double</i>, x=><i>integer</i>, y=><i>integer</i></td> 1084 <td>simulate an image shadow</td> 1085 </tr> 1086 1087 <tr> 1088 <td>Sharpen</td> 1089 <td>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, Alpha, Red, RGB, Yellow}</td> 1090 <td>sharpen the image with a Gaussian operator of the given radius and standard deviation (sigma).</td> 1091 </tr> 1092 1093 <tr> 1094 <td>Shave</td> 1095 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> 1096 <td>shave pixels from the image edges</td> 1097 </tr> 1098 1099 <tr> 1100 <td>Shear</td> 1101 <td>geometry=><i>geometry</i>, x=><i>double</i>, y=><i>double</i> fill=><i><a href="color.html">color name</a></i></td> 1102 <td>shear the image along the X or Y axis by a positive or negative shear angle</td> 1103 </tr> 1104 1105 <tr> 1106 <td>SigmoidalContrast</td> 1107 <td>geometry=><i>string</i>, 'contrast'=><i>double</i>, 'mid-point'=><i>double</i> channel=>{Red, RGB, All, etc.}, sharpen=>{True, False}</td> 1108 <td>sigmoidal non-lineraity contrast control. Increase the contrast of the image using a sigmoidal transfer function without saturating highlights or shadows. <var>Contrast</var> indicates how much to increase the contrast (0 is none; 3 is typical; 20 is a lot); <var>mid-point</var> 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> 1109 </tr> 1110 1111 <tr> 1112 <td>Signature</td> 1113 <td><br /></td> 1114 <td>generate an SHA-256 message digest for the image pixel stream</td> 1115 </tr> 1116 1117 <tr> 1118 <td>Sketch</td> 1119 <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, angle=><i>double</i></td> 1120 <td>sketch the image with a Gaussian operator of the given radius and standard deviation (sigma) at the given angle</td> 1121 </tr> 1122 1123 <tr> 1124 <td>Solarize</td> 1125 <td>geometry=><i>string</i>, threshold=><i>double</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 1126 <td>negate all pixels above the threshold level</td> 1127 </tr> 1128 1129 <tr> 1130 <td>SparseColor</td> 1131 <td>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> 1132 <td>interpolate the image colors around the supplied points</td> 1133 </tr> 1134 1135 <tr> 1136 <td>Splice</td> 1137 <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>, background=><i><a href="color.html">color name</a></i>, gravity=>{NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> 1138 <td>splice an image</td> 1139 </tr> 1140 1141 <tr> 1142 <td>Spread</td> 1143 <td>radius=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td> 1144 <td>displace image pixels by a random amount</td> 1145 </tr> 1146 1147 <tr> 1148 <td>Statistic</td> 1149 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}, type=>{Median, Mode, Mean, Maximum, Minimum, ReduceNoise, RMS}</td> 1150 <td>replace each pixel with corresponding statistic from the neighborhood.</td> 1151 </tr> 1152 <tr> 1153 <td>Stegano</td> 1154 <td>image=><i>image-handle</i>, offset=><i>integer</i></td> 1155 <td>hide a digital watermark within the image</td> 1156 </tr> 1157 1158 <tr> 1159 <td>Stereo</td> 1160 <td>image=><i>image-handle</i>, x=><i>integer</i>, y=><i>integer</i></td> 1161 <td>composites two images and produces a single image that is the composite of a left and right image of a stereo pair</td> 1162 </tr> 1163 1164 <tr> 1165 <td>Strip</td> 1166 <td><br /></td> 1167 <td>strip an image of all profiles and comments.</td> 1168 </tr> 1169 1170 <tr> 1171 <td>Swirl</td> 1172 <td>degrees=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td> 1173 <td>swirl image pixels about the center</td> 1174 </tr> 1175 1176 <tr> 1177 <td>Texture</td> 1178 <td>texture=><i>image-handle</i></td> 1179 <td>name of texture to tile onto the image background</td> 1180 </tr> 1181 1182 <tr> 1183 <td>Thumbnail</td> 1184 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i></td> 1185 <td>changes the size of an image to the given dimensions and removes any associated profiles.</td> 1186 </tr> 1187 1188 <tr> 1189 <td>Threshold</td> 1190 <td>threshold=><i>string</i>, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 1191 <td>threshold the image</td> 1192 </tr> 1193 1194 <tr> 1195 <td>Tint</td> 1196 <td>fill=><i><a href="color.html">color name</a></i>, blend=><i>string</i></td> 1197 <td>tint the image with the fill color.</td> 1198 </tr> 1199 1200 <tr> 1201 <td>Transparent</td> 1202 <td>color=><i><a href="color.html">color name</a></i>, invert=>{True, False}</td> 1203 <td>make this color transparent within the image</td> 1204 </tr> 1205 1206 <tr> 1207 <td>Transpose</td> 1208 <td><br /></td> 1209 <td>flip image in the vertical direction and rotate 90 degrees</td> 1210 </tr> 1211 1212 <tr> 1213 <td>Transverse</td> 1214 <td><br /></td> 1215 <td>flop image in the horizontal direction and rotate 270 degrees</td> 1216 </tr> 1217 1218 <tr> 1219 <td>Trim</td> 1220 <td><br /></td> 1221 <td>remove edges that are the background color from the image</td> 1222 </tr> 1223 1224 <tr> 1225 <td>UnsharpMask</td> 1226 <td>geometry=><i>geometry</i>, radius=><i>double</i>, sigma=><i>double</i>, gain=><i>double</i>, threshold=><i>double</i></td> 1227 <td>sharpen the image with the unsharp mask algorithm.</td> 1228 </tr> 1229 1230 <tr> 1231 <td>Vignette</td> 1232 <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="color.html">color name</a></i></td> 1233 <td>offset the edges of the image in vignette style</td> 1234 </tr> 1235 1236 <tr> 1237 <td>Wave</td> 1238 <td>geometry=><i>geometry</i>, amplitude=><i>double</i>, wavelength=><i>double</i>, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}</td> 1239 <td>alter an image along a sine wave</td> 1240 </tr> 1241 1242 <tr> 1243 <td>WaveDenoise</td> 1244 <td>geometry=><i>geometry</i>, threshold=><i>double</i>, threshold=><i>double</i></td> 1245 <td>removes noise from the image using a wavelet transform</td> 1246 </tr> 1247 1248 <tr> 1249 <td>WhiteThreshold</td> 1250 <td>threshold=><i>string</i>, , channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Alpha, Red, RGB, Yellow}</td> 1251 <td>force all pixels above the threshold intensity into white</td> 1252 </tr> 1253</tbody> 1254</table> 1255 1256<p>Note, that the <code>geometry</code> parameter is a short cut for the <code>width</code> and <code>height</code> parameters (e.g. <code>geometry=>'106x80'</code> is equivalent to <code>width=>106, height=>80</code> ).</p> 1257 1258<p>You can specify <code>@filename</code> in both Annotate() and Draw(). This reads the text or graphic primitive instructions from a file on disk. For example,</p> 1259 1260<pre class="highlight"><code>image->Draw(fill=>'red', primitive=>'rectangle', 1261 points=>'20,20 100,100 40,40 200,200 60,60 300,300'); 1262</code></pre> 1263 1264<p>Is equivalent to</p> 1265 1266<pre class="highlight"><code>$image->Draw(fill=>'red', primitive=>'@draw.txt'); 1267</code></pre> 1268 1269<p>Where <code>draw.txt</code> is a file on disk that contains this:</p> 1270 1271<pre class="highlight"><code>rectangle 20, 20 100, 100 1272rectangle 40, 40 200, 200 1273rectangle 60, 60 300, 300 1274</code></pre> 1275 1276<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> 1277 1278<pre class="pre-scrollable"><code>%b file size 1279%c comment 1280%d directory 1281%e filename extension 1282%f filename 1283%g page geometry 1284%h height 1285%i input filename 1286%k number of unique colors 1287%l label 1288%m magick 1289%n number of scenes 1290%o output filename 1291%p page number 1292%q quantum depth 1293%r image class and colorspace 1294%s scene number 1295%t top of filename 1296%u unique temporary filename 1297%w width 1298%x x resolution 1299%y y resolution 1300%z image depth 1301%C image compression type 1302%D image dispose method 1303%H page height 1304%Q image compression quality 1305%T image delay 1306%W page width 1307%X page x offset 1308%Y page y offset 1309%@ bounding box 1310%# signature 1311%% a percent sign 1312\n newline 1313\r carriage return 1314</code></pre> 1315 1316<p>For example,</p> 1317 1318<pre class="highlight"><code>text=>"%m:%f %wx%h" 1319</code></pre> 1320 1321<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> 1322 1323<p>You can optionally add <i>Image</i> to any method name. For example, TrimImage() is an alias for method Trim().</p> 1324 1325<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> 1326 1327<h2><a class="anchor" id="set-attribute"></a>Set an Image Attribute</h2> 1328 1329<p>Use method Set() to set an image attribute. For example,</p> 1330 1331<pre class="highlight"><code>$image->Set(dither=>'True'); 1332$image->[$x]->Set(delay=>3); 1333</code></pre> 1334 1335<p>Where this example uses 'True' and this document says '{True, False}', 1336you can use the case-insensitive strings 'True' and 'False', or you 1337can use the integers 1 and 0.</p> 1338 1339<p>When you call Get() on a Boolean attribute, Image::Magick returns 1 or 0, not a string.</p> 1340 1341<p>And here is a list of all the image attributes you can set:</p> 1342 1343<table class="table table-sm table-striped"> 1344 <caption>Image Attributes</caption> 1345 <tbody> 1346 <tr> 1347 <th>Attribute</th> 1348 <th style="width: 40%">Values</th> 1349 <th style="width: 40%">Description</th> 1350 </tr> 1351 1352 <tr> 1353 <td>adjoin</td> 1354 <td>{True, False}</td> 1355 <td>join images into a single multi-image file</td> 1356 </tr> 1357 1358 <tr> 1359 <td>alpha</td> 1360 <td>{On, Off, Opaque, Transparent, Copy, Extract, Set}</td> 1361 <td>control of and special operations involving the alpha/matte channel</td> 1362 </tr> 1363 1364 <tr> 1365 <td>antialias</td> 1366 <td>{True, False}</td> 1367 <td>remove pixel aliasing</td> 1368 </tr> 1369 1370 <tr> 1371 <td>area-limit</td> 1372 <td><i>integer</i></td> 1373 <td>set pixel area resource limit.</td> 1374 </tr> 1375 1376 <tr> 1377 <td>attenuate</td> 1378 <td><i>double</i></td> 1379 <td>lessen (or intensify) when adding noise to an image.</td> 1380 </tr> 1381 1382 <tr> 1383 <td>authenticate</td> 1384 <td><i>string</i></td> 1385 <td>decrypt image with this password.</td> 1386 </tr> 1387 1388 <tr> 1389 <td>background</td> 1390 <td><i><a href="color.html">color name</a></i></td> 1391 <td>image background color</td> 1392 </tr> 1393 1394 <tr> 1395 <td>blue-primary</td> 1396 <td><i>x-value</i>, <i>y-value</i></td> 1397 <td>chromaticity blue primary point (e.g. 0.15, 0.06)</td> 1398 </tr> 1399 1400 <tr> 1401 <td>bordercolor</td> 1402 <td><i><a href="color.html">color name</a></i></td> 1403 <td>set the image border color</td> 1404 </tr> 1405 1406 <tr> 1407 <td>clip-mask</td> 1408 <td><i>image</i></td> 1409 <td>associate a clip mask with the image.</td> 1410 </tr> 1411 1412 <tr> 1413 <td>colormap[<i>i</i>]</td> 1414 <td><i><a href="color.html">color name</a></i></td> 1415 <td>color name (e.g. red) or hex value (e.g. #ccc) at position 1416<i>i</i></td> 1417 </tr> 1418 1419 <tr> 1420 <td>comment</td> 1421 <td><i>string</i></td> 1422 <td>set the image comment</td> 1423 </tr> 1424 1425 <tr> 1426 <td>compression</td> 1427 <td>{None, BZip, Fax, Group4, JPEG, JPEG2000, LosslessJPEG, LZW, RLE, Zip}</td> 1428 <td>type of image compression</td> 1429 </tr> 1430 1431 <tr> 1432 <td>debug</td> 1433 <td>{All, Annotate, Blob, Cache, Coder, Configure, Deprecate, Draw, Exception, Locale, None, Resource, Transform, X11}</td> 1434 <td>display copious debugging information</td> 1435 </tr> 1436 1437 <tr> 1438 <td>delay</td> 1439 <td><i>integer</i></td> 1440 <td>this many 1/100ths of a second must expire before displaying the next image in a sequence</td> 1441 </tr> 1442 1443 <tr> 1444 <td>density</td> 1445 <td><i>geometry</i></td> 1446 <td>vertical and horizontal resolution in pixels of the image</td> 1447 </tr> 1448 1449 <tr> 1450 <td>depth</td> 1451 <td><i>integer</i></td> 1452 <td>image depth</td> 1453 </tr> 1454 1455 <tr> 1456 <td>direction</td> 1457 <td><i>{Undefined, right-to-left, left-to-right</i></td> 1458 <td>render text right-to-left or left-to-right</td> 1459 </tr> 1460 1461 <tr> 1462 <td>disk-limit</td> 1463 <td><i>integer</i></td> 1464 <td>set disk resource limit</td> 1465 </tr> 1466 1467 <tr> 1468 <td>dispose</td> 1469 <td><i>{Undefined, None, Background, Previous}</i></td> 1470 <td>layer disposal method</td> 1471 </tr> 1472 1473 <tr> 1474 <td>dither</td> 1475 <td>{True, False}</td> 1476 <td>apply error diffusion to the image</td> 1477 </tr> 1478 1479 <tr> 1480 <td>display</td> 1481 <td><i>string</i></td> 1482 <td>specifies the X server to contact</td> 1483 </tr> 1484 1485 <tr> 1486 <td>extract</td> 1487 <td><i>geometry</i></td> 1488 <td>extract area from image</td> 1489 </tr> 1490 1491 <tr> 1492 <td>file</td> 1493 <td><i>filehandle</i></td> 1494 <td>set the image filehandle</td> 1495 </tr> 1496 1497 <tr> 1498 <td>filename</td> 1499 <td><i>string</i></td> 1500 <td>set the image filename</td> 1501 </tr> 1502 1503 <tr> 1504 <td>fill</td> 1505 <td><i>color</i></td> 1506 <td>The fill color paints any areas inside the outline of drawn shape.</td> 1507 </tr> 1508 1509 <tr> 1510 <td>font</td> 1511 <td><i>string</i></td> 1512 <td>use this font when annotating the image with text</td> 1513 </tr> 1514 1515 <tr> 1516 <td>fuzz</td> 1517 <td><i>integer</i></td> 1518 <td>colors within this distance are considered equal</td> 1519 </tr> 1520 1521 <tr> 1522 <td>gamma</td> 1523 <td><i>double</i></td> 1524 <td>gamma level of the image</td> 1525 </tr> 1526 1527 <tr> 1528 <td>Gravity</td> 1529 <td>{Forget, NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast}</td> 1530 <td>type of image gravity</td> 1531 </tr> 1532 1533 <tr> 1534 <td>green-primary</td> 1535 <td><i>x-value</i>, <i>y-value</i></td> 1536 <td>chromaticity green primary point (e.g. 0.3, 0.6)</td> 1537 </tr> 1538 1539 <tr> 1540 <td>index[<i>x</i>, <i>y</i>]</td> 1541 <td><i>string</i></td> 1542 <td>colormap index at position (<i>x</i>, <i>y</i>)</td> 1543 </tr> 1544 1545 <tr> 1546 <td>interlace</td> 1547 <td>{None, Line, Plane, Partition, JPEG, GIF, PNG}</td> 1548 <td>the type of interlacing scheme</td> 1549 </tr> 1550 1551 <tr> 1552 <td>iterations</td> 1553 <td><i>integer</i></td> 1554 <td>add Netscape loop extension to your GIF animation</td> 1555 </tr> 1556 1557 <tr> 1558 <td>label</td> 1559 <td><i>string</i></td> 1560 <td>set the image label</td> 1561 </tr> 1562 1563 <tr> 1564 <td>loop</td> 1565 <td><i>integer</i></td> 1566 <td>add Netscape loop extension to your GIF animation</td> 1567 </tr> 1568 1569 <tr> 1570 <td>magick</td> 1571 <td><i>string</i></td> 1572 <td>set the image format</td> 1573 </tr> 1574 1575 <tr> 1576 <td>map-limit</td> 1577 <td><i>integer</i></td> 1578 <td>set map resource limit</td> 1579 </tr> 1580 1581 <tr> 1582 <td>mask</td> 1583 <td><i>image</i></td> 1584 <td>associate a mask with the image.</td> 1585 </tr> 1586 1587 <tr> 1588 <td>matte</td> 1589 <td>{True, False}</td> 1590 <td>enable the image matte channel</td> 1591 </tr> 1592 1593 <tr> 1594 <td>mattecolor</td> 1595 <td><i><a href="color.html">color name</a></i></td> 1596 <td>set the image matte color</td> 1597 </tr> 1598 1599 <tr> 1600 <td>memory-limit</td> 1601 <td><i>integer</i></td> 1602 <td>set memory resource limit</td> 1603 </tr> 1604 1605 <tr> 1606 <td>monochrome</td> 1607 <td>{True, False}</td> 1608 <td>transform the image to black and white</td> 1609 </tr> 1610 1611 <tr> 1612 <td>option</td> 1613 <td><i>string</i></td> 1614 <td>associate an option with an image format (e.g. option=>'ps:imagemask'</td> 1615 </tr> 1616 1617 <tr> 1618 <td>orientation</td> 1619 <td>{top-left, top-right, bottom-right, bottom-left, left-top, right-top, right-bottom, left-bottom}</td> 1620 <td>image orientation</td> 1621 </tr> 1622 1623 <tr> 1624 <td>page</td> 1625 <td>{ Letter, Tabloid, Ledger, Legal, Statement, Executive, A3, A4, A5, B4, B5, Folio, Quarto, 10x14} or <i>geometry</i></td> 1626 <td>preferred size and location of an image canvas</td> 1627 </tr> 1628 1629 <tr> 1630 <td>pixel[<i>x</i>, <i>y</i>]</td> 1631 <td><i>string</i></td> 1632 <td>hex value (e.g. #ccc) at position (<i>x</i>, <i>y</i>)</td> 1633 </tr> 1634 1635 <tr> 1636 <td>pointsize</td> 1637 <td><i>integer</i></td> 1638 <td>pointsize of the Postscript or TrueType font</td> 1639 </tr> 1640 1641 <tr> 1642 <td>quality</td> 1643 <td><i>integer</i></td> 1644 <td>JPEG/MIFF/PNG compression level</td> 1645 </tr> 1646 1647 <tr> 1648 <td>red-primary</td> 1649 <td><i>x-value</i>, <i>y-value</i></td> 1650 <td>chromaticity red primary point (e.g. 0.64, 0.33)</td> 1651 </tr> 1652 1653 <tr> 1654 <td>sampling-factor</td> 1655 <td><i>geometry</i></td> 1656 <td>horizontal and vertical sampling factor</td> 1657 </tr> 1658 1659 <tr> 1660 <td>scene</td> 1661 <td><i>integer</i></td> 1662 <td>image scene number</td> 1663 </tr> 1664 1665 <tr> 1666 <td>server</td> 1667 <td><i>string</i></td> 1668 <td>specifies the X server to contact</td> 1669 </tr> 1670 1671 <tr> 1672 <td>size</td> 1673 <td><i>string</i></td> 1674 <td>width and height of a raw image</td> 1675 </tr> 1676 1677 <tr> 1678 <td>stroke</td> 1679 <td><i>color</i></td> 1680 <td>The stroke color paints along the outline of a shape.</td> 1681 </tr> 1682 1683 <tr> 1684 <td>texture</td> 1685 <td><i>string</i></td> 1686 <td>name of texture to tile onto the image background</td> 1687 </tr> 1688 1689 <tr> 1690 <td>tile-offset</td> 1691 <td><i>geometry</i></td> 1692 <td>image tile offset</td> 1693 </tr> 1694 1695 <tr> 1696 <td>time-limit</td> 1697 <td><i>integer</i></td> 1698 <td>set time resource limit in seconds</td> 1699 </tr> 1700 1701 <tr> 1702 <td>type</td> 1703 <td>{Bilevel, Grayscale, GrayscaleMatte, Palette, PaletteMatte, TrueColor, TrueColorMatte, ColorSeparation, ColorSeparationMatte}</td> 1704 <td>image type</td> 1705 </tr> 1706 1707 <tr> 1708 <td>units</td> 1709 <td>{ Undefined, PixelsPerInch, PixelsPerCentimeter}</td> 1710 <td>units of image resolution</td> 1711 </tr> 1712 1713 <tr> 1714 <td>verbose</td> 1715 <td>{True, False}</td> 1716 <td>print detailed information about the image</td> 1717 </tr> 1718 1719 <tr> 1720 <td>virtual-pixel</td> 1721 <td>{Background Black Constant Dither Edge Gray Mirror Random Tile Transparent White}</td> 1722 <td>the virtual pixel method</td> 1723 </tr> 1724 1725 <tr> 1726 <td>white-point</td> 1727 <td><i>x-value</i>, <i>y-value</i></td> 1728 <td>chromaticity white point (e.g. 0.3127, 0.329)</td> 1729 </tr> 1730 </tbody> 1731</table> 1732 1733<p>Note, that the <code>geometry</code> parameter is a short cut for the <code>width</code> and <code>height</code> parameters (e.g. <code>geometry=>'106x80'</code> is equivalent to <code>width=>106, height=>80</code>).</p> 1734 1735<p>SetAttribute() is an alias for method Set().</p> 1736 1737<p>Most of the attributes listed above have an analog in 1738<a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p> 1739 1740<h2><a class="anchor" id="get-attribute"></a>Get an Image Attribute</h2> 1741 1742<p>Use method Get() to get an image attribute. For example,</p> 1743 1744<pre class="highlight"><code>($a, $b, $c) = $image->Get('colorspace', 'magick', 'adjoin'); 1745$width = $image->[3]->Get('columns'); 1746</code></pre> 1747 1748<p>In addition to all the attributes listed in <a href="perl-magick.html#set-attribute">Set an Image Attribute</a> , you can get these additional attributes:</p> 1749 1750<table class="table table-sm table-striped"> 1751 <caption>Image Attributes</caption> 1752 <tbody> 1753 <tr> 1754 <th>Attribute</th> 1755 <th>Values</th> 1756 <th style="width: 60%">Description</th> 1757 </tr> 1758 1759 <tr> 1760 <td>area</td> 1761 <td><i>integer</i></td> 1762 <td>current area resource consumed</td> 1763 </tr> 1764 1765 <tr> 1766 <td>base-columns</td> 1767 <td><i>integer</i></td> 1768 <td>base image width (before transformations)</td> 1769 </tr> 1770 1771 <tr> 1772 <td>base-filename</td> 1773 <td><i>string</i></td> 1774 <td>base image filename (before transformations)</td> 1775 </tr> 1776 1777 <tr> 1778 <td>base-rows</td> 1779 <td><i>integer</i></td> 1780 <td>base image height (before transformations)</td> 1781 </tr> 1782 1783 <tr> 1784 <td>class</td> 1785 <td>{Direct, Pseudo}</td> 1786 <td>image class</td> 1787 </tr> 1788 1789 <tr> 1790 <td>colors</td> 1791 <td><i>integer</i></td> 1792 <td>number of unique colors in the image</td> 1793 </tr> 1794 1795 <tr> 1796 <td>columns</td> 1797 <td><i>integer</i></td> 1798 <td>image width</td> 1799 </tr> 1800 1801 <tr> 1802 <td>copyright</td> 1803 <td><i>string</i></td> 1804 <td>get PerlMagick's copyright</td> 1805 </tr> 1806 1807 <tr> 1808 <td>directory</td> 1809 <td><i>string</i></td> 1810 <td>tile names from within an image montage</td> 1811 </tr> 1812 1813 <tr> 1814 <td>elapsed-time</td> 1815 <td><i>double</i></td> 1816 <td>elapsed time in seconds since the image was created</td> 1817 </tr> 1818 1819 <tr> 1820 <td>error</td> 1821 <td><i>double</i></td> 1822 <td>the mean error per pixel computed with methods Compare() or Quantize()</td> 1823 </tr> 1824 1825 <tr> 1826 <td>bounding-box</td> 1827 <td><i>string</i></td> 1828 <td>image bounding box</td> 1829 </tr> 1830 1831 <tr> 1832 <td>disk</td> 1833 <td><i>integer</i></td> 1834 <td>current disk resource consumed</td> 1835 </tr> 1836 1837 <tr> 1838 <td>filesize</td> 1839 <td><i>integer</i></td> 1840 <td>number of bytes of the image on disk</td> 1841 </tr> 1842 1843 <tr> 1844 <td>format</td> 1845 <td><i>string</i></td> 1846 <td>get the descriptive image format</td> 1847 </tr> 1848 1849 <tr> 1850 <td>geometry</td> 1851 <td><i>string</i></td> 1852 <td>image geometry</td> 1853 </tr> 1854 1855 <tr> 1856 <td>height</td> 1857 <td><i>integer</i></td> 1858 <td>the number of rows or height of an image</td> 1859 </tr> 1860 1861 <tr> 1862 <td>icc</td> 1863 <td><i>string</i></td> 1864 <td>ICC profile</td> 1865 </tr> 1866 1867 <tr> 1868 <td>icc</td> 1869 <td><i>string</i></td> 1870 <td>ICM profile</td> 1871 </tr> 1872 1873 <tr> 1874 <td>id</td> 1875 <td><i>integer</i></td> 1876 <td>ImageMagick registry id</td> 1877 </tr> 1878 1879 <tr> 1880 <td>IPTC</td> 1881 <td><i>string</i></td> 1882 <td>IPTC profile</td> 1883 </tr> 1884 1885 <tr> 1886 <td>mean-error</td> 1887 <td><i>double</i></td> 1888 <td>the normalized mean error per pixel computed with methods Compare() or Quantize()</td> 1889 </tr> 1890 1891 <tr> 1892 <td>map</td> 1893 <td><i>integer</i></td> 1894 <td>current memory-mapped resource consumed</td> 1895 </tr> 1896 1897 <tr> 1898 <td>matte</td> 1899 <td>{True, False}</td> 1900 <td>whether or not the image has a matte channel</td> 1901 </tr> 1902 1903 <tr> 1904 <td>maximum-error</td> 1905 <td><i>double</i></td> 1906 <td>the normalized max error per pixel computed with methods Compare() or Quantize()</td> 1907 </tr> 1908 1909 <tr> 1910 <td>memory</td> 1911 <td><i>integer</i></td> 1912 <td>current memory resource consumed</td> 1913 </tr> 1914 1915 <tr> 1916 <td>mime</td> 1917 <td><i>string</i></td> 1918 <td>MIME of the image format</td> 1919 </tr> 1920 1921 <tr> 1922 <td>montage</td> 1923 <td><i>geometry</i></td> 1924 <td>tile size and offset within an image montage</td> 1925 </tr> 1926 1927 <tr> 1928 <td>page.x</td> 1929 <td><i>integer</i></td> 1930 <td>x offset of image virtual canvas</td> 1931 </tr> 1932 1933 <tr> 1934 <td>page.y</td> 1935 <td><i>integer</i></td> 1936 <td>y offset of image virtual canvas</td> 1937 </tr> 1938 1939 <tr> 1940 <td>rows</td> 1941 <td><i>integer</i></td> 1942 <td>the number of rows or height of an image</td> 1943 </tr> 1944 1945 <tr> 1946 <td>signature</td> 1947 <td><i>string</i></td> 1948 <td>SHA-256 message digest associated with the image pixel stream</td> 1949 </tr> 1950 1951 <tr> 1952 <td>taint</td> 1953 <td>{True, False}</td> 1954 <td>True if the image has been modified</td> 1955 </tr> 1956 1957 <tr> 1958 <td>total-ink-density</td> 1959 <td><i>double</i></td> 1960 <td>returns the total ink density for a CMYK image</td> 1961 </tr> 1962 1963 <tr> 1964 <td>transparent-color</td> 1965 <td><i><a href="color.html">color name</a></i></td> 1966 <td>set the image transparent color</td> 1967 </tr> 1968 1969 <tr> 1970 <td>user-time</td> 1971 <td><i>double</i></td> 1972 <td>user time in seconds since the image was created</td> 1973 </tr> 1974 1975 <tr> 1976 <td>version</td> 1977 <td><i>string</i></td> 1978 <td>get PerlMagick's version</td> 1979 </tr> 1980 1981 <tr> 1982 <td>width</td> 1983 <td><i>integer</i></td> 1984 <td>the number of columns or width of an image</td> 1985 </tr> 1986 1987 <tr> 1988 <td>XMP</td> 1989 <td><i>string</i></td> 1990 <td>XMP profile</td> 1991 </tr> 1992 1993 <tr> 1994 <td>x-resolution</td> 1995 <td><i>integer</i></td> 1996 <td>x resolution of the image</td> 1997 </tr> 1998 1999 <tr> 2000 <td>y-resolution</td> 2001 <td><i>integer</i></td> 2002 <td>y resolution of the image</td> 2003 </tr> 2004 </tbody> 2005</table> 2006 2007<p>GetAttribute() is an alias for method Get().</p> 2008 2009<p>Most of the attributes listed above have an analog in 2010<a href="../www/convert.html">convert</a>. See the documentation for a more detailed description of these attributes.</p> 2011 2012<h2><a class="anchor" id="compare"></a>Compare an Image to its Reconstruction</h2> 2013 2014<p>Mathematically and visually annotate the difference between an image and its reconstruction with the Compare() method. The method supports these parameters:</p> 2015 2016<table class="table table-sm table-striped"> 2017 <caption>Compare Parameters</caption> 2018 <tbody> 2019 <tr> 2020 <th>Parameter</th> 2021 <th style="width: 40%">Values</th> 2022 <th style="width: 40%">Description</th> 2023 </tr> 2024 2025 <tr> 2026 <td>channel</td> 2027 <td><i>double</i></td> 2028 <td>select image channels, the default is all channels except alpha.</td> 2029 </tr> 2030 2031 <tr> 2032 <td>fuzz</td> 2033 <td><i>double</i></td> 2034 <td>colors within this distance are considered equal</td> 2035 </tr> 2036 2037 <tr> 2038 <td>image</td> 2039 <td><i>image-reference</i></td> 2040 <td>the image reconstruction</td> 2041 </tr> 2042 2043 <tr> 2044 <td>metric</td> 2045 <td>AE, MAE, MEPP, MSE, PAE, PSNR, RMSE</td> 2046 <td>measure differences between images with this metric</td> 2047 </tr> 2048 </tbody> 2049</table> 2050 2051<p>In this example, we compare the ImageMagick logo to a sharpened reconstruction:</p> 2052 2053<pre class="highlight"><code>use Image::Magick; 2054 2055$logo=Image::Magick->New(); 2056$logo->Read('logo:'); 2057$sharp=Image::Magick->New(); 2058$sharp->Read('logo:'); 2059$sharp->Sharpen('0x1'); 2060$difference=$logo->Compare(image=>$sharp, metric=>'rmse'); 2061print $difference->Get('error'), "\n"; 2062$difference->Display(); 2063</code></pre> 2064 2065<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> 2066 2067<h2><a class="anchor" id="montage"></a>Create an Image Montage</h2> 2068 2069<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> 2070 2071<pre class="highlight"><code>$image->Montage(geometry=>'160x160', tile=>'2x2', texture=>'granite:'); 2072</code></pre> 2073 2074<p>And here is a list of Montage() parameters you can set:</p> 2075 2076<table class="table table-sm table-striped"> 2077 <caption>Montage Parameters</caption> 2078 <tbody> 2079 <tr> 2080 <th>Parameter</th> 2081 <th style="width: 40%">Values</th> 2082 <th style="width: 40%">Description</th> 2083 </tr> 2084 2085 <tr> 2086 <td>background</td> 2087 <td><i><a href="color.html">color name</a></i></td> 2088 <td>background color name</td> 2089 </tr> 2090 2091 <tr> 2092 <td>border</td> 2093 <td><i>integer</i></td> 2094 <td>image border width</td> 2095 </tr> 2096 2097 <tr> 2098 <td>filename</td> 2099 <td><i>string</i></td> 2100 <td>name of montage image</td> 2101 </tr> 2102 2103 <tr> 2104 <td>fill</td> 2105 <td><a href="color.html">color name</a></td> 2106 <td>fill color for annotations</td> 2107 </tr> 2108 2109 <tr> 2110 <td>font</td> 2111 <td><i>string</i></td> 2112 <td>X11 font name</td> 2113 </tr> 2114 2115 <tr> 2116 <td>frame</td> 2117 <td><i>geometry</i></td> 2118 <td>surround the image with an ornamental border</td> 2119 </tr> 2120 2121 <tr> 2122 <td>geometry</td> 2123 <td><i>geometry</i></td> 2124 <td>preferred tile and border size of each tile of the composite 2125image (e.g. 120x120+4+3>)</td> 2126 </tr> 2127 2128 <tr> 2129 <td>gravity</td> 2130 <td>NorthWest, North, NorthEast, West, Center, East, SouthWest, 2131South, SouthEast</td> 2132 <td>direction image gravitates to within a tile</td> 2133 </tr> 2134 2135 <tr> 2136 <td>label</td> 2137 <td><i>string</i></td> 2138 <td>assign a label to an image</td> 2139 </tr> 2140 2141 <tr> 2142 <td>mode</td> 2143 <td>Frame, Unframe, Concatenate</td> 2144 <td>thumbnail framing options</td> 2145 </tr> 2146 2147 <tr> 2148 <td>pointsize</td> 2149 <td><i>integer</i></td> 2150 <td>pointsize of the Postscript or TrueType font</td> 2151 </tr> 2152 2153 <tr> 2154 <td>shadow</td> 2155 <td>{True, False}</td> 2156 <td>add a shadow beneath a tile to simulate depth</td> 2157 </tr> 2158 2159 <tr> 2160 <td>stroke</td> 2161 <td><a href="color.html">color name</a></td> 2162 <td>stroke color for annotations</td> 2163 </tr> 2164 2165 <tr> 2166 <td>texture</td> 2167 <td><i>string</i></td> 2168 <td>name of texture to tile onto the image background</td> 2169 </tr> 2170 2171 <tr> 2172 <td>tile</td> 2173 <td><i>geometry</i></td> 2174 <td>the number of tiles per row and page (e.g. 6x4)</td> 2175 </tr> 2176 2177 <tr> 2178 <td>title</td> 2179 <td>string</td> 2180 <td>assign a title to the image montage</td> 2181 </tr> 2182 2183 <tr> 2184 <td>transparent</td> 2185 <td><i>string</i></td> 2186 <td>make this color transparent within the image</td> 2187 </tr> 2188 </tbody> 2189</table> 2190 2191<p>Note, that the <code>geometry</code> parameter is a short cut for the <code>width</code> and <code>height</code> parameters (e.g. <code>geometry=>'106x80'</code> is equivalent to <code>width=>106, height=>80</code>).</p> 2192 2193<p>MontageImage() is an alias for method Montage().</p> 2194 2195<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> 2196 2197<h2><a class="anchor" id="blobs"></a>Working with Blobs</h2> 2198 2199<p>A blob contains data that directly represent a particular image 2200format in memory instead of on disk. PerlMagick supports 2201blobs 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> 2202 2203<table class="table table-sm table-striped"> 2204 <caption>Blob Methods</caption> 2205 <tbody> 2206 <tr> 2207 <th>Method</th> 2208 <th>Parameters</th> 2209 <th>Return Value</th> 2210 <th>Description</th> 2211 </tr> 2212 2213 <tr> 2214 <td>ImageToBlob</td> 2215 <td>any image <a href="perl-magick.html#set-attribute">attribute</a></td> 2216 <td>an array of image data in the respective image format</td> 2217 <td>convert an image or image sequence to an array of blobs</td> 2218 </tr> 2219 2220 <tr> 2221 <td>BlobToImage</td> 2222 <td>one or more blobs</td> 2223 <td>the number of blobs converted to an image</td> 2224 <td>convert one or more blobs to an image</td> 2225 </tr> 2226 </tbody> 2227</table> 2228 2229<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> 2230 2231<pre class="highlight"><code>@blobs = $image->ImageToBlob(); 2232open(DISPLAY,"| display -") || die; 2233binmode DISPLAY; 2234print DISPLAY $blobs[0]; 2235close DISPLAY; 2236</code></pre> 2237 2238<p>Method BlobToImage() returns an image or image sequence converted from the supplied blob:</p> 2239 2240<pre class="highlight"><code>@blob=$db->GetImage(); 2241$image=Image::Magick->new(magick=>'jpg'); 2242$image->BlobToImage(@blob); 2243</code></pre> 2244 2245<h2><a class="anchor" id="direct-access"></a>Direct-access to Image Pixels</h2> 2246 2247<p>Use these methods to obtain direct access to the image pixels:</p> 2248 2249<table class="table table-sm table-striped"> 2250<caption>Direct-access to Image Pixels</caption> 2251<tbody> 2252 <tr> 2253 <th>Method</th> 2254 <th>Parameters</th> 2255 <th style="width: 50%">Description</th> 2256 </tr> 2257 2258 <tr> 2259 <td>GetAuthenticPixels</td> 2260 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i></td> 2261 <td>return authentic pixels as a C pointer</td> 2262 </tr> 2263 2264 <tr> 2265 <td>GetVirtualPixels</td> 2266 <td>geometry=><i>geometry</i>, width=><i>integer</i>, height=><i>integer</i>, x=><i>integer</i>, y=><i>integer</i></td> 2267 <td>return virtual pixels as a const C pointer</td> 2268 </tr> 2269 2270 <tr> 2271 <td>GetAuthenticIndexQueue</td> 2272 <td></td> 2273 <td>return colormap indexes or black pixels as a C pointer</td> 2274 </tr> 2275 2276 <tr> 2277 <td>GetVirtualIndexQueue</td> 2278 <td></td> 2279 <td>return colormap indexes or black pixels as a const C pointer</td> 2280 </tr> 2281 2282 <tr> 2283 <td>SyncAuthenticPixels</td> 2284 <td></td> 2285 <td>sync authentic pixels to pixel cache</td> 2286 </tr> 2287 2288</tbody> 2289</table> 2290 2291<h2><a class="anchor" id="miscellaneous"></a>Miscellaneous Methods</h2> 2292 2293<p>The Append() method append a set of images. For example,</p> 2294 2295<pre class="highlight"><code>$p = $image->Append(stack=>{true,false}); 2296</code></pre> 2297 2298<p>appends all the images associated with object <code>$image</code>. By default, images are stacked left-to-right. Set <code>stack</code> to True to stack them top-to-bottom.</p> 2299 2300<p>The Clone() method copies a set of images. For example,</p> 2301 2302<pre class="highlight"><code>$q = $p->Clone(); 2303</code></pre> 2304 2305<p>copies all the images from object <code>$p</code> to <code>$q</code>. You can use this method for single or multi-image sequences.</p> 2306 2307<p>The ComplexImages() method performs complex mathematics on an image sequence. For example,</p> 2308 2309<pre class="highlight"><code>$p = $image->ComplexImages('conjugate'); 2310</code></pre> 2311 2312<p>The EvaluateImages() method applies an arithmetic, logical or relational expression to a set of images. For example,</p> 2313 2314 2315<pre class="highlight"><code>$p = $image->EvaluateImages('mean'); 2316</code></pre> 2317 2318<p>averages all the images associated with object <code>$image</code>.</p> 2319 2320<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> 2321 2322<pre class="highlight"><code>@features = $image->Features(1); 2323</code></pre> 2324 2325<p>The Flatten() method flattens a set of images and returns it. For example,</p> 2326 2327<pre class="highlight"><code>$p = $images->Flatten(background=>'none'); 2328$p->Write('flatten.png'); 2329</code></pre> 2330 2331<p>The sequence of images is replaced by a single image created by composing each image after the first over the first image.</p> 2332 2333<p>The Fx() method applies a mathematical expression to a set of images and returns the results. For example,</p> 2334 2335<pre class="highlight"><code>$p = $image->Fx(expression=>'(g+b)/2.0',channel=>'red'); 2336$p->Write('fx.miff'); 2337</code></pre> 2338 2339<p>replaces the red channel with the average of the green and blue channels.</p> 2340 2341<p>See <a href="fx.html">FX, The Special Effects Image Operator</a> for a detailed discussion of this method.</p> 2342 2343<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> 2344 2345<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> 2346 2347<pre class="highlight"><code>$p = $image->Morph(frames=><i>integer</i>); 2348</code></pre> 2349 2350<p>where <i>frames</i> is the number of in-between images to generate. The default is 1.</p> 2351 2352<p>Mosaic() creates an mosaic from an image sequence.</p> 2353 2354<p>Method Mogrify() is a single entry point for the image manipulation methods (<a href="perl-magick.html#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> 2355 2356<pre class="highlight"><code>$image->Crop('340x256+0+0'); 2357$image->Mogrify('crop', '340x256+0+0'); 2358</code></pre> 2359 2360<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> 2361 2362<pre class="highlight"><code>$image->MogrifyRegion('100x100+40+50', 'modulate', brightness=>50); 2363</code></pre> 2364 2365<p>PerceptualHash() maps visually identical images to the same or similar hash-- useful in image retrieval, authentication, indexing, or copy detection as well as digital watermarking. For each channel and for the sRGB and the HCLp colorspaces, 7 hash values are returned For an sRGB images, for example, expect 42 perceptual hashes.</p> 2366 2367<pre class="highlight"><code>@phash = $image->PerceptualHash();</code></pre> 2368 2369<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> 2370 2371<pre class="highlight"><code>($width, $height, $size, $format) = $image->Ping('logo.png'); 2372($width, $height, $size, $format) = $image->Ping(file=>\*IMAGE); 2373($width, $height, $size, $format) = $image->Ping(blob=>$blob); 2374</code></pre> 2375 2376<p>This a more efficient and less memory intensive way to query if an image exists and what its characteristics are.</p> 2377 2378<p>Poly() builds a polynomial from the image sequence and the corresponding terms (coefficients and degree pairs):</p> 2379 2380<pre class="highlight"><code>$p = $image->Poly([0.5,1.0,0.25,2.0,1.0,1.0]); 2381</code></pre> 2382 2383<p>PreviewImage() 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: <code>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</code>. Here is an example:</p> 2384 2385<pre class="highlight"><code>$preview = $image->Preview('Gamma'); 2386$preview->Display(); 2387</code></pre> 2388 2389<p>To have full control over text positioning you need font metric information. Use</p> 2390 2391<pre class="highlight"><code>($x_ppem, $y_ppem, $ascender, $descender, $width, $height, $max_advance) = 2392 $image->QueryFontMetrics(<i>parameters</i>); 2393</code></pre> 2394 2395<p>Where <i>parameters</i> is any parameter of the <a href="perl-magick.html#manipulate">Annotate</a> method. The return values are:</p> 2396 2397<ol> 2398 <li>character width</li> 2399 <li>character height</li> 2400 <li>ascender</li> 2401 <li>descender</li> 2402 <li>text width</li> 2403 <li>text height</li> 2404 <li>maximum horizontal advance</li> 2405 <li>bounds: x1</li> 2406 <li>bounds: y1</li> 2407 <li>bounds: x2</li> 2408 <li>bounds: y2</li> 2409 <li>origin: x</li> 2410 <li>origin: y</li> 2411</ol> 2412 2413<p>Use QueryMultilineFontMetrics() to get the maximum text width and height for multiple lines of text.</p> 2414 2415<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> 2416 2417<pre class="highlight"><code>@colors = $image->QueryColor(); 2418($red, $green, $blue) = $image->QueryColor('cyan'); 2419($red, $green, $blue, $alpha) = $image->QueryColor('#716baeff'); 2420</code></pre> 2421 2422<p>QueryColorname() accepts a color value and returns its respective name or hex value;</p> 2423 2424<pre class="highlight"><code>$name = $image->QueryColorname('rgba(80,60,0,0)'); 2425</code></pre> 2426 2427<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> 2428 2429<pre class="highlight"><code>@fonts = $image->QueryFont(); 2430$weight = ($image->QueryFont('Helvetica'))[5]; 2431</code></pre> 2432 2433<p>Call QueryFormat() with no parameters to return a list of known image formats or specify one or more format names to get these attributes: adjoin, blob support, raw, decoder, encoder, description, and module.</p> 2434 2435<pre class="highlight"><code>@formats = $image->QueryFormat(); 2436($adjoin, $blob_support, $raw, $decoder, $encoder, $description, $module) = 2437 $image->QueryFormat('gif'); 2438</code></pre> 2439 2440<p>Call MagickToMime() with the image format name to get its MIME type such as <code>images/tiff</code> from <code>tif</code>.</p> 2441 2442<pre class="highlight"><code>$mime = $image->MagickToMime('tif'); 2443</code></pre> 2444 2445<p>Use RemoteCommand() to send a command to an already running <a href="../www/display.html">display</a> or <a href="animate.html">animate</a> application. The only parameter is the name of the image file to display or animate.</p> 2446 2447<pre class="highlight"><code>$image->RemoteCommand('image.jpg'); 2448</code></pre> 2449 2450<p>The Smush() method smushes a set of images together. For example,</p> 2451 2452<pre class="highlight"><code>$p = $image->Smush(stack=>{true,false},offset=><var>integer</var>); 2453</code></pre> 2454 2455<p>smushes together all the images associated with object <code>$image</code>. By default, images are smushed left-to-right. Set <code>stack</code> to True to smushed them top-to-bottom.</p> 2456 2457<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, skewness, and entropy values in RGB, CMYK, RGBA, or CMYKA order (depending on the image type).</p> 2458 2459<pre class="highlight"><code>@statistics = $image->Statistics(); 2460</code></pre> 2461 2462<p>Finally, the Transform() method accepts a fully-qualified geometry specification for cropping or resizing one or more images. For example,</p> 2463 2464<pre class="highlight"><code>$p = $image->Transform(crop=>'100x100+0+0'); 2465</code></pre> 2466 2467<p>You can optionally add <i>Image</i> to any method name above. For example, PingImage() is an alias for method Ping().</p> 2468 2469<h2><a class="anchor" id="exceptions"></a>Handling Exceptions</h2> 2470 2471<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> 2472 2473<p>Methods which return a number (e.g. Read(), Write()):</p> 2474 2475<pre class="highlight"><code>$x = $image->Read(...); 2476warn "$x" if "$x"; # print the error message 2477$x =~ /(\d+)/; 2478print $1; # print the error number 2479print 0+$x; # print the number of images read 2480</code></pre> 2481 2482<p>Methods which operate on an image (e.g. Resize(), Crop()):</p> 2483 2484<pre class="highlight"><code>$x = $image->Crop(...); 2485warn "$x" if "$x"; # print the error message 2486$x =~ /(\d+)/; 2487print $1; # print the error number 2488</code></pre> 2489 2490<p>Methods which return images (EvaluateSequence(), Montage(), Clone()) should be checked for errors this way:</p> 2491 2492<pre class="highlight"><code>$x = $image->Montage(...); 2493warn "$x" if !ref($x); # print the error message 2494$x =~ /(\d+)/; 2495print $1; # print the error number 2496</code></pre> 2497 2498<p>Here is an example error message:</p> 2499 2500<pre class="highlight"><code>Error 400: Memory allocation failed 2501</code></pre> 2502 2503<p>Review the complete list of <a href="exception.html">error and warning codes</a>.</p> 2504 2505<p>The following illustrates how you can use a numeric status code:</p> 2506 2507<pre class="highlight"><code>$x = $image->Read('rose.png'); 2508$x =~ /(\d+)/; 2509die "unable to continue" if ($1 == ResourceLimitError); 2510</code></pre> 2511 2512<h2><a class="anchor" id="constants"></a>Constants</h2> 2513 2514<p>PerlMagick includes these constants:</p> 2515 2516<pre class="pre-scrollable"><code>BlobError 2517BlobWarning 2518CacheError 2519CacheWarning 2520CoderError 2521CoderWarning 2522ConfigureError 2523ConfigureWarning 2524CorruptImageError 2525CorruptImageWarning 2526DelegateError 2527DelegateWarning 2528DrawError 2529DrawWarning 2530ErrorException 2531FatalErrorException 2532FileOpenError 2533FileOpenWarning 2534ImageError 2535ImageWarning 2536MissingDelegateError 2537MissingDelegateWarning 2538ModuleError 2539ModuleWarning 2540Opaque 2541OptionError 2542OptionWarning 2543QuantumDepth 2544QuantumRange 2545RegistryError 2546RegistryWarning 2547ResourceLimitError 2548ResourceLimitWarning 2549StreamError 2550StreamWarning 2551Success 2552Transparent 2553TypeError 2554TypeWarning 2555WarningException 2556XServerError 2557XServerWarning 2558</code></pre> 2559 2560<p>You can access them like this:</p> 2561 2562<pre class="highlight"><code>Image::Magick->QuantumDepth 2563</code></pre> 2564 2565</div> 2566 </div> 2567 </main><!-- /.container --> 2568 <footer class="magick-footer"> 2569 <p><a href="../www/security-policy.html">Security</a> • 2570 <a href="../www/architecture.html">Architecture</a> • 2571 <a href="../www/links.html">Related</a> • 2572 <a href="../www/sitemap.html">Sitemap</a> 2573 2574 <a href="perl-magick.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../images/wand.ico"/></a> 2575 2576 <a href="http://pgp.mit.edu/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> • 2577 <a href="../www/support.html">Donate</a> • 2578 <a href="../www/https://imagemagick.org/script/contact.php">Contact Us</a> 2579 <br/> 2580 <small>© 1999-2019 ImageMagick Studio LLC</small></p> 2581 </footer> 2582 2583 <!-- Javascript assets --> 2584 <script src="assets/magick.js" crossorigin="anonymous"></script> 2585 <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>')</script> 2586</body> 2587</html> 2588