]> granicus.if.org Git - imagemagick/blob - www/api/layer.html
(no commit message)
[imagemagick] / www / api / layer.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" \r
2   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">\r
4 <head>\r
5   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\r
6   <meta name="verify-v1" content="g222frIIxcQTrvDR3NBRUSKP3AnMNoqxOkIniCEkV7U="/>\r
7   <title>ImageMagick: MagickCore, C API for ImageMagick: Dealing with Image Layers</title>
8   <meta http-equiv="Content-Language" content="en-US"/>
9   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
10   <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
11   <meta name="Application-name" content="ImageMagick"/>
12   <meta name="Description" content="ImageMagick is a software suite to create, edit, compose, or convert bitmap images in a variety of formats. Use ImageMagick to scale, rotate, shear, distort and transform images."/>
13   <meta name="Application-url" content="http://www.imagemagick.org"/>
14   <meta name="Generator" content="PHP"/>
15   <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"/>
16   <meta name="Rating" content="GENERAL"/>
17   <meta name="Robots" content="INDEX, FOLLOW"/>
18   <meta name="Generator" content="ImageMagick Studio LLC"/>
19   <meta name="Author" content="ImageMagick Studio LLC"/>
20   <meta name="Revisit-after" content="2 DAYS"/>
21   <meta name="Resource-type" content="document"/>
22   <meta name="Copyright" content="Copyright (c) 1999-2011 ImageMagick Studio LLC"/>
23   <meta name="Distribution" content="Global"/>
24   <link rel="icon" href="../../images/wand.png"/>
25   <link rel="shortcut icon" href="../../images/wand.ico"  type="images/x-icon"/>
26   <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>\r
27   <style type="text/css" media="all">\r
28     @import url("../../www/magick.css");\r
29   </style>\r
30   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>\r
31   <script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>\r
32   <link rel="stylesheet" type="text/css" href="../fancybox/jquery.fancybox-1.3.4.css" media="screen" />\r
33   <script type="text/javascript">\r
34     $(document).ready(function() {\r
35       $("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({\r
36         'transitionIn'  : 'elastic',\r
37         'transitionOut' : 'elastic',\r
38         'overlayShow'   : false,\r
39         'opacity'       : true\r
40       });\r
41     });\r
42   </script>\r
43 </head>\r
44 \r
45 <body id="www-imagemagick-org">\r
46 <div class="titlebar">\r
47 <a href="../../index.html">\r
48   <img src="../../images/script.png" alt="[ImageMagick]"\r
49   style="width: 350px; height: 60px; margin: 28px auto; float: left;" /></a>\r
50 <a href="http://www.networkredux.com">\r
51   <img src="../../images/networkredux.png" alt="[sponsor]"\r
52   style="margin: 45px auto; border: 0px; float: left;" /></a>\r
53 <a href="http://www.imagemagick.org/discourse-server/">\r
54   <img src="../../images/logo.jpg" alt=""\r
55   style="width: 114px; height: 118px; border: 0px; float: right;" /></a>\r
56 <a href="../../index.html">\r
57   <img src="../../images/sprite.jpg" alt=""\r
58   style="width: 114px; height: 118px; border: 0px; float: right;" /></a>\r
59 </div>\r
60 \r
61 <div class="westbar">\r
62 \r
63 <div class="menu">
64   <a title="About ImageMagick" href="../../index.html">About ImageMagick</a>
65 </div>
66 <div class="sep"></div>\r
67 <div class="menu">
68   <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
69 </div>
70 <div class="sub">
71     <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
72 </div>
73 <div class="sub">
74     <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
75 </div>
76 <div class="sub">
77     <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
78 </div>
79 <div class="sep"></div>\r
80 <div class="menu">
81   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
82 </div>
83 <div class="sub">
84     <a title="Command-line Tools: Processing" href="../../www/command-line-processing.html">Processing</a>
85 </div>
86 <div class="sub">
87     <a title="Command-line Tools: Options" href="../../www/command-line-options.html">Options</a>
88 </div>
89 <div class="sub">
90     <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
91 </div>
92 <div class="menu">
93   <a title="Program Interfaces" href="../../www/api.html">Program Interfaces</a>
94 </div>
95 <div class="sub">
96     <a title="Program Interface: MagickWand" href="../../www/magick-wand.html">MagickWand</a>
97 </div>
98 <div class="sub">
99     <a title="Program Interface: MagickCore" href="../../www/magick-core.html">MagickCore</a>
100 </div>
101 <div class="sub">
102     <a title="Program Interface: PerlMagick" href="../../www/perl-magick.html">PerlMagick</a>
103 </div>
104 <div class="sub">
105     <a title="Program Interface: Magick++" href="../../www/magick++.html">Magick++</a>
106 </div>
107 <div class="sep"></div>\r
108 <div  class="menu">
109    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
110 </div>
111 <div class="sub">
112     <a title="Install from Source: Unix" href="../../www/install-source.html#unix">Unix</a>
113 </div>
114 <div class="sub">
115     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
116  </div>
117 <div class="menu">
118   <a title="Resources" href="../../www/resources.html">Resources</a>
119 </div>
120 <div class="menu">
121   <a title="Architecture" href="../../www/architecture.html">Architecture</a>
122 </div>
123 <div class="menu">
124   <a title="Download" href="../../www/download.html">Download</a>
125 </div>
126 <div class="sep"></div>\r
127 <div class="menu">
128   <a title="Search" href="../http://www.imagemagick.org/script/search.php">Search</a>
129 </div>
130 <div class="sep"></div>\r
131 <div class="menu">
132   <a title="Site Map" href="../../www/sitemap.html">Site Map</a>
133 </div>
134 <div  class="sub">
135   <a title="Site Map: Links" href="../../www/links.html">Links</a>
136 </div>
137 <div class="sep"></div>\r
138 <div  class="menu">
139   <a title="Sponsors" href="../../www/sponsors.html">Sponsors:</a>
140
141 <div class="sponsbox">
142 <div  class="sponsor">
143    <a title="Sponsor: Webdesign" href="http://www.renehornig.com/">Webdesign</a><!-- 20111001000240 -->
144 </div>
145 <div  class="sponsor">
146   <a title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 201110010720 -->
147 </div>
148 <div  class="sponsor">
149   <a title="Sponsor: Image Converter" href="http://www.batchphoto.com">Image Converter</a><!-- 201103010900 Bits Coffee-->
150 </div>
151 <div  class="sponsor">
152   <a title="Sponsor: Flyer drucken" href="http://www.online-druck.biz">Flyer drucken</a><!-- 201109010900 Floeter-->
153 </div>
154 </div>
155 </div>
156 </div>\r
157 \r
158 <div class="eastbar">\r
159   <script type="text/javascript">\r
160   <!--\r
161     google_ad_client = "pub-3129977114552745";\r
162     google_ad_slot = "0574824969";\r
163     google_ad_width = 160;\r
164     google_ad_height = 600;\r
165   //-->\r
166   </script>\r
167   <script type="text/javascript"\r
168     src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\r
169   </script>\r
170 </div>\r
171 \r
172 <div class="main">\r
173 \r
174 <h1>Module layer
175  Methods</h1>
176 <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>
177
178 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
179 _8c.html" target="source" name="CoalesceImages">CoalesceImages</a></h2>
180 <div class="doc-section">
181
182 <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>
183
184 <p>The format of the CoalesceImages method is:</p>
185
186 <pre class="code">
187   Image *CoalesceImages(Image *image,ExceptionInfo *exception)
188 </pre>
189
190 <p>A description of each parameter follows:</p></ol>
191
192 <h5>image</h5>
193 <ol><p>the image sequence.</p></ol>
194
195 <h5>exception</h5>
196 <ol><p>return any errors or warnings in this structure.</p></ol>
197
198  </div>
199 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
200 _8c.html" target="source" name="DisposeImages">DisposeImages</a></h2>
201 <div class="doc-section">
202
203 <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>
204
205 <p>The format of the DisposeImages method is:</p>
206
207 <pre class="code">
208   Image *DisposeImages(Image *image,ExceptionInfo *exception)
209 </pre>
210
211 <p>A description of each parameter follows:</p></ol>
212
213 <h5>image</h5>
214 <ol><p>the image sequence.</p></ol>
215
216 <h5>exception</h5>
217 <ol><p>return any errors or warnings in this structure.</p></ol>
218
219  </div>
220 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
221 _8c.html" target="source" name="CompareImageLayers">CompareImageLayers</a></h2>
222 <div class="doc-section">
223
224 <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>
225
226 <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>
227
228 <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>
229
230 <p>The format of the CompareImageLayers method is:</p>
231
232 <pre class="code">
233   Image *CompareImageLayers(const Image *images,
234     const ImageLayerMethod method,ExceptionInfo *exception)
235 </pre>
236
237 <p>A description of each parameter follows:</p></ol>
238
239 <h5>image</h5>
240 <ol><p>the image.</p></ol>
241
242 <h5>method</h5>
243 <ol><p>the layers type to compare images with. Must be one of... CompareAnyLayer, CompareClearLayer, CompareOverlayLayer.</p></ol>
244
245 <h5>exception</h5>
246 <ol><p>return any errors or warnings in this structure.</p></ol>
247
248  </div>
249 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
250 _8c.html" target="source" name="DeconstructImages">DeconstructImages</a></h2>
251 <div class="doc-section">
252
253 <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>
254
255 <p>This function is deprecated in favor of the more universal CompareImageLayers() function.</p></ol>
256
257 <p>The format of the DeconstructImages method is:</p>
258
259 <pre class="code">
260   Image *DeconstructImages(const Image *images, ExceptionInfo *exception)
261 </pre>
262
263 <p>A description of each parameter follows:</p></ol>
264
265 <h5>image</h5>
266 <ol><p>the image.</p></ol>
267
268 <h5>exception</h5>
269 <ol><p>return any errors or warnings in this structure.</p></ol>
270
271  </div>
272 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
273 _8c.html" target="source" name="OptimizeImageLayers">OptimizeImageLayers</a></h2>
274 <div class="doc-section">
275
276 <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>
277
278 <p>The format of the OptimizeImageLayers method is:</p>
279
280 <pre class="code">
281   Image *OptimizeImageLayers(const Image *image,
282            ExceptionInfo *exception)
283 </pre>
284
285 <p>A description of each parameter follows:</p></ol>
286
287 <h5>image</h5>
288 <ol><p>the image.</p></ol>
289
290 <h5>exception</h5>
291 <ol><p>return any errors or warnings in this structure.</p></ol>
292
293  </div>
294 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
295 _8c.html" target="source" name="OptimizeImagePlusLayers">OptimizeImagePlusLayers</a></h2>
296 <div class="doc-section">
297
298 <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>
299
300 <p>The format of the OptimizePlusImageLayers method is:</p>
301
302 <pre class="code">
303   Image *OptimizePlusImageLayers(const Image *image,
304            ExceptionInfo *exception)
305 </pre>
306
307 <p>A description of each parameter follows:</p></ol>
308
309 <h5>image</h5>
310 <ol><p>the image.</p></ol>
311
312 <h5>exception</h5>
313 <ol><p>return any errors or warnings in this structure.</p></ol>
314
315  </div>
316 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
317 _8c.html" target="source" name="OptimizeImageTransparency">OptimizeImageTransparency</a></h2>
318 <div class="doc-section">
319
320 <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>
321
322 <p>WARNING: This modifies the current images directly, rather than generate a new image sequence.</p></ol>
323
324 <p>The format of the OptimizeImageTransperency method is:</p>
325
326 <pre class="code">
327   void OptimizeImageTransperency(Image *image,ExceptionInfo *exception)
328 </pre>
329
330 <p>A description of each parameter follows:</p></ol>
331
332 <h5>image</h5>
333 <ol><p>the image sequence</p></ol>
334
335 <h5>exception</h5>
336 <ol><p>return any errors or warnings in this structure.</p></ol>
337
338  </div>
339 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
340 _8c.html" target="source" name="RemoveDuplicateLayers">RemoveDuplicateLayers</a></h2>
341 <div class="doc-section">
342
343 <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>
344
345 <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>
346
347 <p>The format of the RemoveDuplicateLayers method is:</p>
348
349 <pre class="code">
350   void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception)
351 </pre>
352
353 <p>A description of each parameter follows:</p></ol>
354
355 <h5>images</h5>
356 <ol><p>the image list</p></ol>
357
358 <h5>exception</h5>
359 <ol><p>return any errors or warnings in this structure.</p></ol>
360
361  </div>
362 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
363 _8c.html" target="source" name="RemoveZeroDelayLayers">RemoveZeroDelayLayers</a></h2>
364 <div class="doc-section">
365
366 <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>
367
368 <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>
369
370 <p>No warning will be given if no image was removed because all images had an appropriate non-zero time delay set.</p></ol>
371
372 <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>
373
374 <p>The format of the RemoveZeroDelayLayers method is:</p>
375
376 <pre class="code">
377   void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception)
378 </pre>
379
380 <p>A description of each parameter follows:</p></ol>
381
382 <h5>images</h5>
383 <ol><p>the image list</p></ol>
384
385 <h5>exception</h5>
386 <ol><p>return any errors or warnings in this structure.</p></ol>
387
388  </div>
389 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
390 _8c.html" target="source" name="CompositeLayers">CompositeLayers</a></h2>
391 <div class="doc-section">
392
393 <p>CompositeLayers() compose first image sequence (source) over the second image sequence (destination), using the given compose method and offsets.</p></ol>
394
395 <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>
396
397 <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>
398
399 <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>
400
401 <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>
402
403 <p>The format of the CompositeLayers method is:</p>
404
405 <pre class="code">
406   void CompositeLayers(Image *destination,
407       const CompositeOperator compose, Image *source,
408       const ssize_t x_offset, const ssize_t y_offset,
409       ExceptionInfo *exception);
410 </pre>
411
412 <p>A description of each parameter follows:</p></ol>
413
414 <h5>destination</h5>
415 <ol><p>the destination images and results</p></ol>
416
417 <h5>source</h5>
418 <ol><p>source image(s) for the layer composition</p></ol>
419
420 <h5>compose, x_offset, y_offset</h5>
421 <ol><p>arguments passed on to CompositeImages()</p></ol>
422
423 <h5>exception</h5>
424 <ol><p>return any errors or warnings in this structure.</p></ol>
425
426  </div>
427 <h2><a href="http://www.imagemagick.org/api/MagickCore/layer
428 _8c.html" target="source" name="MergeImageLayers">MergeImageLayers</a></h2>
429 <div class="doc-section">
430
431 <p>MergeImageLayers() composes all the image layers from the current given image onward to produce a single image of the merged layers.</p></ol>
432
433 <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>
434
435 <p>The format of the MergeImageLayers is:</p>
436
437 <pre class="text">
438   Image *MergeImageLayers(const Image *image,
439     const ImageLayerMethod method, ExceptionInfo *exception)
440 </pre>
441
442 <p>A description of each parameter follows:</p></ol>
443
444 <h5>image</h5>
445 <ol><p>the image list to be composited together</p></ol>
446
447 <h5>method</h5>
448 <ol><p>the method of selecting the size of the initial canvas.</p></ol>
449
450 <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>
451
452 <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>
453
454 <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>
455
456 <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>
457
458 <p>WARNING: a new image is not returned, the original image sequence page data is modified instead.</p></ol>
459
460 <h5>exception</h5>
461 <ol><p>return any errors or warnings in this structure.</p></ol>
462
463  </div>
464 \r
465 </div>\r
466 \r
467 <div id="linkbar">\r
468     <span id="linkbar-west">&nbsp;</span>\r
469     <span id="linkbar-center">\r
470       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;\r
471       <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>\r
472     </span>\r
473     <span id="linkbar-east">&nbsp;</span>\r
474   </div>\r
475   <div class="footer">\r
476     <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>\r
477     <span id="footer-east"> <a href="../http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>\r
478   </div>\r
479   <div style="clear: both; margin: 0; width: 100%; "></div>\r
480   <script type="text/javascript">\r
481     var _gaq = _gaq || [];\r
482     _gaq.push(['_setAccount', 'UA-17690367-1']);\r
483     _gaq.push(['_trackPageview']);\r
484 \r
485     (function() {\r
486       var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\r
487       ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\r
488       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\r
489     })();\r
490   </script>\r
491 </body>\r
492 </html>\r