Debian Codegraph @

www/perl-magick.html

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