blob: 66756fafc7b0f7f4e9c5d53c9dc8be25e9033adb [file] [log] [blame]
cristyb32b90a2009-09-07 21:45:48 +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"/>
cristyb32b90a2009-09-07 21:45:48 +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>
cristyb32b90a2009-09-07 21:45:48 +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>
cristyb32b90a2009-09-07 21:45:48 +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>
cristyb32b90a2009-09-07 21:45:48 +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>
cristyb32b90a2009-09-07 21:45:48 +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>
cristyb32b90a2009-09-07 21:45:48 +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>
cristyb32b90a2009-09-07 21:45:48 +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">
126 <a href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012001200 allesdruck.de-->
127</div>
128<div class="sponsor">
129 <a href="http://www.blumenversender.com">Blumenversand</a><!-- 200911010120 -->
130</div>
131<div class="sponsor">
132 <a href="http://www.print24.de/">Druckerei</a><!-- 200911010480 -->
133</div>
134<div class="sponsor">
135 <a href="http://www.who-sells-it.com/">Free Catalogs</a><!-- 201002010000 -->
136</div>
137<div class="sponsor">
138 <a href="http://www.online-kredit-index.de">Kredit</a><!-- 201001010120 Buchhorn -->
139</div>
140</div>
141</div>
cristyb32b90a2009-09-07 21:45:48 +0000142
143
144</div>
145
146<div class="main">
147
cristy3ed852e2009-09-05 21:47:34 +0000148<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>
149
150<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
151_8c.html" target="source" name="CoalesceImages">CoalesceImages</a></h2>
152<div class="doc-section">
153
154<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>
155
156<p>The format of the CoalesceImages method is:</p>
157
158<pre class="code">
159 Image *CoalesceImages(Image *image,ExceptionInfo *exception)
160</pre>
161
162<p>A description of each parameter follows:</p></ol>
163
164<h5>image</h5>
165<ol><p>the image sequence.</p></ol>
166
167<h5>exception</h5>
168<ol><p>return any errors or warnings in this structure.</p></ol>
169
170 </div>
171<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
172_8c.html" target="source" name="DisposeImages">DisposeImages</a></h2>
173<div class="doc-section">
174
175<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>
176
177<p>The format of the DisposeImages method is:</p>
178
179<pre class="code">
180 Image *DisposeImages(Image *image,ExceptionInfo *exception)
181</pre>
182
183<p>A description of each parameter follows:</p></ol>
184
185<h5>image</h5>
186<ol><p>the image sequence.</p></ol>
187
188<h5>exception</h5>
189<ol><p>return any errors or warnings in this structure.</p></ol>
190
191 </div>
192<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
193_8c.html" target="source" name="CompareImageLayers">CompareImageLayers</a></h2>
194<div class="doc-section">
195
196<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>
197
198<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>
199
200<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>
201
202<p>The format of the CompareImageLayers method is:</p>
203
204<pre class="code">
205 Image *CompareImageLayers(const Image *images,
206 const ImageLayerMethod method,ExceptionInfo *exception)
207</pre>
208
209<p>A description of each parameter follows:</p></ol>
210
211<h5>image</h5>
212<ol><p>the image.</p></ol>
213
214<h5>method</h5>
215<ol><p>the layers type to compare images with. Must be one of... CompareAnyLayer, CompareClearLayer, CompareOverlayLayer.</p></ol>
216
217<h5>exception</h5>
218<ol><p>return any errors or warnings in this structure.</p></ol>
219
220 </div>
221<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
222_8c.html" target="source" name="DeconstructImages">DeconstructImages</a></h2>
223<div class="doc-section">
224
225<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>
226
227<p>This function is deprecated in favor of the more universal CompareImageLayers() function.</p></ol>
228
229<p>The format of the DeconstructImages method is:</p>
230
231<pre class="code">
232 Image *DeconstructImages(const Image *images, ExceptionInfo *exception)
233</pre>
234
235<p>A description of each parameter follows:</p></ol>
236
237<h5>image</h5>
238<ol><p>the image.</p></ol>
239
240<h5>exception</h5>
241<ol><p>return any errors or warnings in this structure.</p></ol>
242
243 </div>
244<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
245_8c.html" target="source" name="OptimizeImageLayers">OptimizeImageLayers</a></h2>
246<div class="doc-section">
247
248<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>
249
250<p>The format of the OptimizeImageLayers method is:</p>
251
252<pre class="code">
253 Image *OptimizeImageLayers(const Image *image,
254 ExceptionInfo *exception)
255</pre>
256
257<p>A description of each parameter follows:</p></ol>
258
259<h5>image</h5>
260<ol><p>the image.</p></ol>
261
262<h5>exception</h5>
263<ol><p>return any errors or warnings in this structure.</p></ol>
264
265 </div>
266<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
267_8c.html" target="source" name="OptimizeImagePlusLayers">OptimizeImagePlusLayers</a></h2>
268<div class="doc-section">
269
270<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>
271
272<p>The format of the OptimizePlusImageLayers method is:</p>
273
274<pre class="code">
275 Image *OptimizePlusImageLayers(const Image *image,
276 ExceptionInfo *exception)
277</pre>
278
279<p>A description of each parameter follows:</p></ol>
280
281<h5>image</h5>
282<ol><p>the image.</p></ol>
283
284<h5>exception</h5>
285<ol><p>return any errors or warnings in this structure.</p></ol>
286
287 </div>
288<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
289_8c.html" target="source" name="OptimizeImageTransparency">OptimizeImageTransparency</a></h2>
290<div class="doc-section">
291
292<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>
293
294<p>WARNING: This modifies the current images directly, rather than generate a new image sequence.</p></ol>
295
296<p>The format of the OptimizeImageTransperency method is:</p>
297
298<pre class="code">
299 void OptimizeImageTransperency(Image *image,ExceptionInfo *exception)
300</pre>
301
302<p>A description of each parameter follows:</p></ol>
303
304<h5>image</h5>
305<ol><p>the image sequence</p></ol>
306
307<h5>exception</h5>
308<ol><p>return any errors or warnings in this structure.</p></ol>
309
310 </div>
311<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
312_8c.html" target="source" name="RemoveDuplicateLayers">RemoveDuplicateLayers</a></h2>
313<div class="doc-section">
314
315<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>
316
317<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>
318
319<p>The format of the RemoveDuplicateLayers method is:</p>
320
321<pre class="code">
322 void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception)
323</pre>
324
325<p>A description of each parameter follows:</p></ol>
326
327<h5>images</h5>
328<ol><p>the image list</p></ol>
329
330<h5>exception</h5>
331<ol><p>return any errors or warnings in this structure.</p></ol>
332
333 </div>
334<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
335_8c.html" target="source" name="RemoveZeroDelayLayers">RemoveZeroDelayLayers</a></h2>
336<div class="doc-section">
337
338<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>
339
340<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>
341
342<p>No warning will be given if no image was removed because all images had an appropriate non-zero time delay set.</p></ol>
343
344<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>
345
346<p>The format of the RemoveZeroDelayLayers method is:</p>
347
348<pre class="code">
349 void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception)
350</pre>
351
352<p>A description of each parameter follows:</p></ol>
353
354<h5>images</h5>
355<ol><p>the image list</p></ol>
356
357<h5>exception</h5>
358<ol><p>return any errors or warnings in this structure.</p></ol>
359
360 </div>
361<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
362_8c.html" target="source" name="CompositeLayers">CompositeLayers</a></h2>
363<div class="doc-section">
364
365<p>CompositeLayers() compose first image sequence (source) over the second image sequence (destination), using the given compose method and offsets.</p></ol>
366
367<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>
368
369<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>
370
371<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>
372
373<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>
374
375<p>The format of the CompositeLayers method is:</p>
376
377<pre class="code">
378 void CompositeLayers(Image *destination,
379 const CompositeOperator compose, Image *source,
380 const long x_offset, const long y_offset,
381 ExceptionInfo *exception);
382</pre>
383
384<p>A description of each parameter follows:</p></ol>
385
386<h5>destination</h5>
387<ol><p>the destination images and results</p></ol>
388
389<h5>source</h5>
390<ol><p>source image(s) for the layer composition</p></ol>
391
392<h5>compose, x_offset, y_offset</h5>
393<ol><p>arguments passed on to CompositeImages()</p></ol>
394
395<h5>exception</h5>
396<ol><p>return any errors or warnings in this structure.</p></ol>
397
398 </div>
399<h2><a href="http://www.imagemagick.org/api/MagickCore/layer
400_8c.html" target="source" name="MergeImageLayers">MergeImageLayers</a></h2>
401<div class="doc-section">
402
403<p>MergeImageLayers() composes all the image layers from the current given image onward to produce a single image of the merged layers.</p></ol>
404
405<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>
406
407<p>The format of the MergeImageLayers is:</p>
408
409<pre class="text">
410 Image *MergeImageLayers(const Image *image,
411 const ImageLayerMethod method, ExceptionInfo *exception)
412</pre>
413
414<p>A description of each parameter follows:</p></ol>
415
416<h5>image</h5>
417<ol><p>the image list to be composited together</p></ol>
418
419<h5>method</h5>
420<ol><p>the method of selecting the size of the initial canvas.</p></ol>
421
422<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>
423
424<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>
425
426<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>
427
428<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>
429
430<p>WARNING: a new image is not returned, the original image sequence page data is modified instead.</p></ol>
431
432<h5>exception</h5>
433<ol><p>return any errors or warnings in this structure.</p></ol>
434
435 </div>
cristyb32b90a2009-09-07 21:45:48 +0000436
437</div>
438
439<div id="linkbar">
440 <!-- <span id="linkbar-west">&nbsp;</span> -->
441 <span id="linkbar-center">
442 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
443 <a href="../../www/mailing-list.html">Mailing Lists</a> &bull;
444 <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
445 </span>
446 <span id="linkbar-east">&nbsp;</span>
447 </div>
448 <div class="footer">
449 <span id="footer-west">&copy; 1999-2009 ImageMagick Studio LLC</span>
450 <span id="footer-east"> <a href="../http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
451 </div>
452 <div style="clear: both; margin: 0; width: 100%; "></div>
453</body>
454</html>