blob: c05c3b43e8f6d774e3fb711dd7be3954caaee0ac [file] [log] [blame]
cristyf3bb4782009-09-08 13:10:04 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5 <meta name="verify-v1" content="g222frIIxcQTrvDR3NBRUSKP3AnMNoqxOkIniCEkV7U=" />
6 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf" />
7 <style type="text/css" media="screen,projection"><!--
8 @import url("../../www/magick.css");
9 --></style>
cristy3ed852e2009-09-05 21:47:34 +000010 <link rel="shortcut icon" href="../../images/wand.ico" type="images/vnd.microsoft.icon"/>
11 <title>ImageMagick: MagickCore, C API for ImageMagick: Dealing with Image Layers</title>
12 <meta http-equiv="Content-Language" content="en-US"/>
13 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
15 <meta name="Generator" content="PHP"/>
16 <meta name="Keywords" content="magickcore, c, api, for, imagemagick:, dealing, with, image, layers, ImageMagick, ImageMagic, MagickCore, MagickWand, PerlMagick, Magick++, RMagick, PythonMagick, JMagick, TclMagick, Image, Magick, Magic, Wand, ImageMagickObject, Swiss, Army, Knife, Image, Processing"/>
17 <meta name="Description" content="ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you can freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems. The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: MagickCore (C), MagickWand (C), ChMagick (Ch), Magick++ (C++), JMagick (Java), L-Magick (Lisp), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images automagically and dynamically."/>
18 <meta name="Rating" content="GENERAL"/>
19 <meta name="Robots" content="INDEX, FOLLOW"/>
20 <meta name="Generator" content="ImageMagick Studio LLC"/>
21 <meta name="Author" content="ImageMagick Studio LLC"/>
22 <meta name="Revisit-after" content="2 DAYS"/>
23 <meta name="Resource-type" content="document"/>
24 <meta name="Copyright" content="Copyright (c) 1999-2009 ImageMagick Studio LLC"/>
25 <meta name="Distribution" content="Global"/>
cristyf3bb4782009-09-08 13:10:04 +000026</head>
27
28<body id="www-imagemagick-org">
29<div class="titlebar">
30<a href="../../index.html">
31 <img src="../../images/script.png" alt="[ImageMagick]"
32 style="width: 350px; height: 60px; margin: 28px auto; float: left;" /></a>
33<a href="http://www.networkredux.com">
34 <img src="../../images/networkredux.png" alt="[sponsor]"
35 style="margin: 45px auto; border: 0px; float: left;" /></a>
36<a href="http://www.imagemagick.org/discourse-server/">
37 <img src="../../images/logo.jpg" alt=""
38 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
39<a href="../../index.html">
40 <img src="../../images/sprite.jpg" alt=""
41 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
42</div>
43
44<div class="eastbar">
45
cristy3ed852e2009-09-05 21:47:34 +000046<div class="menu">
47 <a href="../../index.html">About ImageMagick</a>
48</div>
cristyf3bb4782009-09-08 13:10:04 +000049<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +000050<div class="menu">
51 <a href="../../www/command-line-tools.html">Command-line Tools</a>
52</div>
53<div class="sub">
54 <a href="../../www/command-line-processing.html">Processing</a>
55</div>
56<div class="sub">
57 <a href="../../www/command-line-options.html">Options</a>
58</div>
59<div class="sub">
60 <a href="http://www.imagemagick.org/Usage/">Usage</a>
61</div>
62<div class="menu">
63 <a href="../../www/api.html">Program Interfaces</a>
64</div>
65<div class="sub">
66 <a href="../../www/magick-wand.html">MagickWand</a>
67</div>
68<div class="sub">
69 <a href="../../www/magick-core.html">MagickCore</a>
70</div>
71<div class="sub">
72 <a href="../../www/perl-magick.html">PerlMagick</a>
73</div>
74<div class="sub">
75 <a href="../../Magick++/">Magick++</a>
76</div>
77<div class="menu">
78 <a href="../../www/architecture.html">Architecture</a>
79</div>
cristyf3bb4782009-09-08 13:10:04 +000080<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +000081<div class="menu">
82 <a href="../../www/install-source.html">Install from Source</a>
83</div>
84<div class="sub">
85 <a href="../../www/install-source.html#unix">Unix</a>
86</div>
87<div class="sub">
88 <a href="../../www/install-source.html#windows">Windows</a>
89 </div>
90<div class="menu">
91 <a href="../../www/binary-releases.html">Binary Releases</a>
92</div>
93<div class="sub">
94 <a href="../../www/binary-releases.html#unix">Unix</a>
95</div>
96<div class="sub">
97 <a href="../../www/binary-releases.html#macosx">Mac OS X</a>
98</div>
99<div class="sub">
100 <a href="../../www/binary-releases.html#windows">Windows</a>
101</div>
102<div class="menu">
103 <a href="../../www/resources.html">Resources</a>
104</div>
cristyf3bb4782009-09-08 13:10:04 +0000105<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000106<div class="menu">
107 <a href="../../www/download.html">Download</a>
108</div>
cristyf3bb4782009-09-08 13:10:04 +0000109<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000110<div class="menu">
111 <a href="../http://www.imagemagick.org/script/search.php">Search</a>
112</div>
cristyf3bb4782009-09-08 13:10:04 +0000113<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000114<div class="menu">
115 <a href="../../www/sitemap.html">Site Map</a>
116</div>
117<div class="sub">
118 <a href="../../www/links.html">Links</a>
119</div>
cristyf3bb4782009-09-08 13:10:04 +0000120<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000121<div class="menu">
122 <a href="../../www/sponsors.html">Sponsors:</a>
123
124<div class="sponsbox">
125<div class="sponsor">
cristyf3bb4782009-09-08 13:10:04 +0000126 <a href="http://www.goyax.de">Börse</a><!-- 201001000240 Gewiese digital-finance.de -->
127</div>
128<div class="sponsor">
cristy3ed852e2009-09-05 21:47:34 +0000129 <a href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012001200 allesdruck.de-->
130</div>
131<div class="sponsor">
132 <a href="http://www.blumenversender.com">Blumenversand</a><!-- 200911010120 -->
133</div>
134<div class="sponsor">
135 <a href="http://www.print24.de/">Druckerei</a><!-- 200911010480 -->
136</div>
137<div class="sponsor">
138 <a href="http://www.who-sells-it.com/">Free Catalogs</a><!-- 201002010000 -->
139</div>
140<div class="sponsor">
cristyf3bb4782009-09-08 13:10:04 +0000141 <a href="http://www.online-kredit-index.de">Kredit</a><!-- 201002010120 Buchhorn -->
cristy3ed852e2009-09-05 21:47:34 +0000142</div>
143</div>
144</div>
cristyf3bb4782009-09-08 13:10:04 +0000145
146
147</div>
148
149<div class="main">
150
cristy3ed852e2009-09-05 21:47:34 +0000151<p class="navigation-index">[<a href="#CoalesceImages">CoalesceImages</a> &bull; <a href="#DisposeImages">DisposeImages</a> &bull; <a href="#CompareImageLayers">CompareImageLayers</a> &bull; <a href="#DeconstructImages">DeconstructImages</a> &bull; <a href="#OptimizeImageLayers">OptimizeImageLayers</a> &bull; <a href="#OptimizeImagePlusLayers">OptimizeImagePlusLayers</a> &bull; <a href="#OptimizeImageTransparency">OptimizeImageTransparency</a> &bull; <a href="#RemoveDuplicateLayers">RemoveDuplicateLayers</a> &bull; <a href="#RemoveZeroDelayLayers">RemoveZeroDelayLayers</a> &bull; <a href="#CompositeLayers">CompositeLayers</a> &bull; <a href="#MergeImageLayers">MergeImageLayers</a>]</p>
152
153<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
154_8c.html" target="source" name="CoalesceImages">CoalesceImages</a></h2>
155<div class="doc-section">
156
157<p>CoalesceImages() composites a set of images while respecting any page offsets and disposal methods. GIF, MIFF, and MNG animation sequences typically start with an image background and each subsequent image varies in size and offset. A new image sequence is returned with all images the same size as the first images virtual canvas and composited with the next image in the sequence.</p></ol>
158
159<p>The format of the CoalesceImages method is:</p>
160
161<pre class="code">
162 Image *CoalesceImages(Image *image,ExceptionInfo *exception)
163</pre>
164
165<p>A description of each parameter follows:</p></ol>
166
167<h5>image</h5>
168<ol><p>the image sequence.</p></ol>
169
170<h5>exception</h5>
171<ol><p>return any errors or warnings in this structure.</p></ol>
172
173 </div>
174<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
175_8c.html" target="source" name="DisposeImages">DisposeImages</a></h2>
176<div class="doc-section">
177
178<p>DisposeImages() returns the coalesced frames of a GIF animation as it would appear after the GIF dispose method of that frame has been applied. That is it returned the appearance of each frame before the next is overlaid.</p></ol>
179
180<p>The format of the DisposeImages method is:</p>
181
182<pre class="code">
183 Image *DisposeImages(Image *image,ExceptionInfo *exception)
184</pre>
185
186<p>A description of each parameter follows:</p></ol>
187
188<h5>image</h5>
189<ol><p>the image sequence.</p></ol>
190
191<h5>exception</h5>
192<ol><p>return any errors or warnings in this structure.</p></ol>
193
194 </div>
195<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
196_8c.html" target="source" name="CompareImageLayers">CompareImageLayers</a></h2>
197<div class="doc-section">
198
199<p>CompareImageLayers() compares each image with the next in a sequence and returns the minimum bounding region of all the pixel differences (of the ImageLayerMethod specified) it discovers.</p></ol>
200
201<p>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 an specific frame should look).</p></ol>
202
203<p>No GIF dispose methods are applied, so GIF animations must be coalesced before applying this image operator to find differences to them.</p></ol>
204
205<p>The format of the CompareImageLayers method is:</p>
206
207<pre class="code">
208 Image *CompareImageLayers(const Image *images,
209 const ImageLayerMethod method,ExceptionInfo *exception)
210</pre>
211
212<p>A description of each parameter follows:</p></ol>
213
214<h5>image</h5>
215<ol><p>the image.</p></ol>
216
217<h5>method</h5>
218<ol><p>the layers type to compare images with. Must be one of... CompareAnyLayer, CompareClearLayer, CompareOverlayLayer.</p></ol>
219
220<h5>exception</h5>
221<ol><p>return any errors or warnings in this structure.</p></ol>
222
223 </div>
224<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
225_8c.html" target="source" name="DeconstructImages">DeconstructImages</a></h2>
226<div class="doc-section">
227
228<p>DeconstructImages() compares each image with the next in a sequence and returns the minimum bounding region of all differences from the first image.</p></ol>
229
230<p>This function is deprecated in favor of the more universal CompareImageLayers() function.</p></ol>
231
232<p>The format of the DeconstructImages method is:</p>
233
234<pre class="code">
235 Image *DeconstructImages(const Image *images, ExceptionInfo *exception)
236</pre>
237
238<p>A description of each parameter follows:</p></ol>
239
240<h5>image</h5>
241<ol><p>the image.</p></ol>
242
243<h5>exception</h5>
244<ol><p>return any errors or warnings in this structure.</p></ol>
245
246 </div>
247<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
248_8c.html" target="source" name="OptimizeImageLayers">OptimizeImageLayers</a></h2>
249<div class="doc-section">
250
251<p>OptimizeImageLayers() compares each image the GIF disposed forms of the previous image in the sequence. From this it attempts to select the smallest cropped image to replace each frame, while preserving the results of the GIF animation.</p></ol>
252
253<p>The format of the OptimizeImageLayers method is:</p>
254
255<pre class="code">
256 Image *OptimizeImageLayers(const Image *image,
257 ExceptionInfo *exception)
258</pre>
259
260<p>A description of each parameter follows:</p></ol>
261
262<h5>image</h5>
263<ol><p>the image.</p></ol>
264
265<h5>exception</h5>
266<ol><p>return any errors or warnings in this structure.</p></ol>
267
268 </div>
269<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
270_8c.html" target="source" name="OptimizeImagePlusLayers">OptimizeImagePlusLayers</a></h2>
271<div class="doc-section">
272
273<p>OptimizeImagePlusLayers() is exactly as OptimizeImageLayers(), but may also add or even remove extra frames in the animation, if it improves the total number of pixels in the resulting GIF animation.</p></ol>
274
275<p>The format of the OptimizePlusImageLayers method is:</p>
276
277<pre class="code">
278 Image *OptimizePlusImageLayers(const Image *image,
279 ExceptionInfo *exception)
280</pre>
281
282<p>A description of each parameter follows:</p></ol>
283
284<h5>image</h5>
285<ol><p>the image.</p></ol>
286
287<h5>exception</h5>
288<ol><p>return any errors or warnings in this structure.</p></ol>
289
290 </div>
291<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
292_8c.html" target="source" name="OptimizeImageTransparency">OptimizeImageTransparency</a></h2>
293<div class="doc-section">
294
295<p>OptimizeImageTransparency() takes a frame optimized GIF animation, and compares the overlayed pixels against the disposal image resulting from all the previous frames in the animation. Any pixel that does not change the disposal image (and thus does not effect the outcome of an overlay) is made transparent.</p></ol>
296
297<p>WARNING: This modifies the current images directly, rather than generate a new image sequence.</p></ol>
298
299<p>The format of the OptimizeImageTransperency method is:</p>
300
301<pre class="code">
302 void OptimizeImageTransperency(Image *image,ExceptionInfo *exception)
303</pre>
304
305<p>A description of each parameter follows:</p></ol>
306
307<h5>image</h5>
308<ol><p>the image sequence</p></ol>
309
310<h5>exception</h5>
311<ol><p>return any errors or warnings in this structure.</p></ol>
312
313 </div>
314<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
315_8c.html" target="source" name="RemoveDuplicateLayers">RemoveDuplicateLayers</a></h2>
316<div class="doc-section">
317
318<p>RemoveDuplicateLayers() removes any image that is exactly the same as the next image in the given image list. Image size and virtual canvas offset must also match, though not the virtual canvas size itself.</p></ol>
319
320<p>No check is made with regards to image disposal setting, though it is the dispose setting of later image that is kept. Also any time delays are also added together. As such coalesced image animations should still produce the same result, though with duplicte frames merged into a single frame.</p></ol>
321
322<p>The format of the RemoveDuplicateLayers method is:</p>
323
324<pre class="code">
325 void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception)
326</pre>
327
328<p>A description of each parameter follows:</p></ol>
329
330<h5>images</h5>
331<ol><p>the image list</p></ol>
332
333<h5>exception</h5>
334<ol><p>return any errors or warnings in this structure.</p></ol>
335
336 </div>
337<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
338_8c.html" target="source" name="RemoveZeroDelayLayers">RemoveZeroDelayLayers</a></h2>
339<div class="doc-section">
340
341<p>RemoveZeroDelayLayers() removes any image that as a zero delay time. Such images generally represent intermediate or partial updates in GIF animations used for file optimization. They are not ment to be displayed to users of the animation. Viewable images in an animation should have a time delay of 3 or more centi-seconds (hundredths of a second).</p></ol>
342
343<p>However if all the frames have a zero time delay, then either the animation is as yet incomplete, or it is not a GIF animation. This a non-sensible situation, so no image will be removed and a 'Zero Time Animation' warning (exception) given.</p></ol>
344
345<p>No warning will be given if no image was removed because all images had an appropriate non-zero time delay set.</p></ol>
346
347<p>Due to the special requirements of GIF disposal handling, GIF animations should be coalesced first, before calling this function, though that is not a requirement.</p></ol>
348
349<p>The format of the RemoveZeroDelayLayers method is:</p>
350
351<pre class="code">
352 void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception)
353</pre>
354
355<p>A description of each parameter follows:</p></ol>
356
357<h5>images</h5>
358<ol><p>the image list</p></ol>
359
360<h5>exception</h5>
361<ol><p>return any errors or warnings in this structure.</p></ol>
362
363 </div>
364<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
365_8c.html" target="source" name="CompositeLayers">CompositeLayers</a></h2>
366<div class="doc-section">
367
368<p>CompositeLayers() compose first image sequence (source) over the second image sequence (destination), using the given compose method and offsets.</p></ol>
369
370<p>The pointers to the image list does not have to be the start of that image list, but may start somewhere in the middle. Each layer from the two image lists are composted together until the end of one of the image lists is reached. The offset of each composition is also adjusted to match the virtual canvas offsets of each layer. As such the given offset is relative to the virtual canvas, and not the actual image.</p></ol>
371
372<p>No GIF disposal handling is performed, so GIF animations should be coalesced before use. However this not a requirement, and individual layer images may have any size or offset, for special compositions.</p></ol>
373
374<p>Special case:- If one of the image sequences is just a single image that image is repeatally composed with all the images in the other image list. Either the source or destination lists may be the single image, for this situation.</p></ol>
375
376<p>The destination list will be expanded as needed to match number of source image overlaid (from current position to end of list).</p></ol>
377
378<p>The format of the CompositeLayers method is:</p>
379
380<pre class="code">
381 void CompositeLayers(Image *destination,
382 const CompositeOperator compose, Image *source,
383 const long x_offset, const long y_offset,
384 ExceptionInfo *exception);
385</pre>
386
387<p>A description of each parameter follows:</p></ol>
388
389<h5>destination</h5>
390<ol><p>the destination images and results</p></ol>
391
392<h5>source</h5>
393<ol><p>source image(s) for the layer composition</p></ol>
394
395<h5>compose, x_offset, y_offset</h5>
396<ol><p>arguments passed on to CompositeImages()</p></ol>
397
398<h5>exception</h5>
399<ol><p>return any errors or warnings in this structure.</p></ol>
400
401 </div>
402<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
403_8c.html" target="source" name="MergeImageLayers">MergeImageLayers</a></h2>
404<div class="doc-section">
405
406<p>MergeImageLayers() composes all the image layers from the current given image onward to produce a single image of the merged layers.</p></ol>
407
408<p>The inital canvas's size depends on the given ImageLayerMethod, and is initialized using the first images background color. The images are then compositied onto that image in sequence using the given composition that has been assigned to each individual image.</p></ol>
409
410<p>The format of the MergeImageLayers is:</p>
411
412<pre class="text">
413 Image *MergeImageLayers(const Image *image,
414 const ImageLayerMethod method, ExceptionInfo *exception)
415</pre>
416
417<p>A description of each parameter follows:</p></ol>
418
419<h5>image</h5>
420<ol><p>the image list to be composited together</p></ol>
421
422<h5>method</h5>
423<ol><p>the method of selecting the size of the initial canvas.</p></ol>
424
425<p>MergeLayer: Merge all layers onto a canvas just large enough to hold all the actual images. The virtual canvas of the first image is preserved but otherwise ignored.</p></ol>
426
427<p>FlattenLayer: Use the virtual canvas size of first image. Images which fall outside this canvas is clipped. This can be used to 'fill out' a given virtual canvas.</p></ol>
428
429<p>MosaicLayer: Start with the virtual canvas of the first image, enlarging left and right edges to contain all images. Images with negative offsets will be clipped.</p></ol>
430
431<p>TrimBoundsLayer: Determine the overall bounds of all the image layers just as in "MergeLayer", then adjust the the canvas and offsets to be relative to those bounds, without overlaying the images.</p></ol>
432
433<p>WARNING: a new image is not returned, the original image sequence page data is modified instead.</p></ol>
434
435<h5>exception</h5>
436<ol><p>return any errors or warnings in this structure.</p></ol>
437
438 </div>
cristyf3bb4782009-09-08 13:10:04 +0000439
440</div>
441
442<div id="linkbar">
443 <!-- <span id="linkbar-west">&nbsp;</span> -->
444 <span id="linkbar-center">
445 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
446 <a href="../../www/mailing-list.html">Mailing Lists</a> &bull;
447 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
448 </span>
449 <span id="linkbar-east">&nbsp;</span>
450 </div>
451 <div class="footer">
452 <span id="footer-west">&copy; 1999-2009 ImageMagick Studio LLC</span>
453 <span id="footer-east"> <a href="../http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
454 </div>
455 <div style="clear: both; margin: 0; width: 100%; "></div>
456</body>
457</html>