• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3
4
5<!DOCTYPE html>
6<html lang="en">
7<head>
8    <title>ImageMagick: MagickCore, C API for ImageMagick: Dealing with Image Layers</title>
9  <meta charset="utf-8" />
10  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
11  <meta name="viewport" content="width=device-width, initial-scale=1" />
12  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13  <meta name="application-name" content="ImageMagick"/>
14  <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves."/>
15  <meta name="application-url" content="http://www.imagemagick.org"/>
16  <meta name="generator" content="PHP"/>
17  <meta name="keywords" content="magickcore, c, api, for, imagemagick:, dealing, with, image, layers, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
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-2016 ImageMagick Studio LLC"/>
25  <meta name="distribution" content="Global"/>
26  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
27  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
28  <link rel="icon" href="../images/wand.png"/>
29  <link rel="shortcut icon" href="../images/wand.ico"/>
30  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
31  <link rel="stylesheet" href="../css/magick.html"/>
32</head>
33<body>
34<div class="main">
35<div class="magick-masthead">
36  <div class="container">
37    <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
38         style="display:block"
39         data-ad-client="ca-pub-3129977114552745"
40         data-ad-slot="6345125851"
41         data-ad-format="auto"></ins>
42    <script>
43      (adsbygoogle = window.adsbygoogle || []).push({});
44    </script>
45    <nav class="magick-nav">
46      <a class="magick-nav-item " href="../index.html">Home</a>
47      <a class="magick-nav-item " href="../binary-releases.html">Download</a>
48      <a class="magick-nav-item " href="../command-line-tools.html">Tools</a>
49      <a class="magick-nav-item " href="../command-line-processing.html">Command-line</a>
50      <a class="magick-nav-item " href="../resources.html">Resources</a>
51      <a class="magick-nav-item " href="api.html">Develop</a>
52      <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
53      <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
54    </nav>
55  </div>
56</div>
57<div class="container">
58<div class="magick-header">
59<p class="text-center"><a href="layer.html#CoalesceImages">CoalesceImages</a> &#8226; <a href="layer.html#DisposeImages">DisposeImages</a> &#8226; <a href="layer.html#CompareImagesLayers">CompareImagesLayers</a> &#8226; <a href="layer.html#OptimizeImageLayers">OptimizeImageLayers</a> &#8226; <a href="layer.html#OptimizeImagePlusLayers">OptimizeImagePlusLayers</a> &#8226; <a href="layer.html#OptimizeImageTransparency">OptimizeImageTransparency</a> &#8226; <a href="layer.html#RemoveDuplicateLayers">RemoveDuplicateLayers</a> &#8226; <a href="layer.html#RemoveZeroDelayLayers">RemoveZeroDelayLayers</a> &#8226; <a href="layer.html#CompositeLayers">CompositeLayers</a> &#8226; <a href="layer.html#MergeImageLayers">MergeImageLayers</a></p>
60
61<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="CoalesceImages">CoalesceImages</a></h2>
62
63<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>
64
65<p>The format of the CoalesceImages method is:</p>
66
67<pre class="text">
68Image *CoalesceImages(Image *image,ExceptionInfo *exception)
69</pre>
70
71<p>A description of each parameter follows:</p>
72
73<dd>
74</dd>
75
76<dd> </dd>
77<dl class="dl-horizontal">
78<dt>image</dt>
79<dd>the image sequence. </dd>
80
81<dd> </dd>
82<dt>exception</dt>
83<dd>return any errors or warnings in this structure. </dd>
84
85<dd>  </dd>
86</dl>
87<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="DisposeImages">DisposeImages</a></h2>
88
89<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>
90
91<p>The format of the DisposeImages method is:</p>
92
93<pre class="text">
94Image *DisposeImages(Image *image,ExceptionInfo *exception)
95</pre>
96
97<p>A description of each parameter follows:</p>
98
99<dd>
100</dd>
101
102<dd> </dd>
103<dl class="dl-horizontal">
104<dt>images</dt>
105<dd>the image sequence. </dd>
106
107<dd> </dd>
108<dt>exception</dt>
109<dd>return any errors or warnings in this structure. </dd>
110
111<dd>  </dd>
112</dl>
113<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="CompareImagesLayers">CompareImagesLayers</a></h2>
114
115<p>CompareImagesLayers() compares each image with the next in a sequence and returns the minimum bounding region of all the pixel differences (of the LayerMethod specified) it discovers.</p>
116
117<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>
118
119<p>No GIF dispose methods are applied, so GIF animations must be coalesced before applying this image operator to find differences to them.</p>
120
121<p>The format of the CompareImagesLayers method is:</p>
122
123<pre class="text">
124Image *CompareImagesLayers(const Image *images,
125  const LayerMethod method,ExceptionInfo *exception)
126</pre>
127
128<p>A description of each parameter follows:</p>
129
130<dd>
131</dd>
132
133<dd> </dd>
134<dl class="dl-horizontal">
135<dt>image</dt>
136<dd>the image. </dd>
137
138<dd> </dd>
139<dt>method</dt>
140<dd>the layers type to compare images with. Must be one of... CompareAnyLayer, CompareClearLayer, CompareOverlayLayer. </dd>
141
142<dd> </dd>
143<dt>exception</dt>
144<dd>return any errors or warnings in this structure. </dd>
145
146<dd>  </dd>
147</dl>
148<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="OptimizeImageLayers">OptimizeImageLayers</a></h2>
149
150<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>
151
152<p>The format of the OptimizeImageLayers method is:</p>
153
154<pre class="text">
155Image *OptimizeImageLayers(const Image *image,
156         ExceptionInfo *exception)
157</pre>
158
159<p>A description of each parameter follows:</p>
160
161<dd>
162</dd>
163
164<dd> </dd>
165<dl class="dl-horizontal">
166<dt>image</dt>
167<dd>the image. </dd>
168
169<dd> </dd>
170<dt>exception</dt>
171<dd>return any errors or warnings in this structure. </dd>
172
173<dd>  </dd>
174</dl>
175<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="OptimizeImagePlusLayers">OptimizeImagePlusLayers</a></h2>
176
177<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>
178
179<p>The format of the OptimizePlusImageLayers method is:</p>
180
181<pre class="text">
182Image *OptimizePlusImageLayers(const Image *image,
183         ExceptionInfo *exception)
184</pre>
185
186<p>A description of each parameter follows:</p>
187
188<dd>
189</dd>
190
191<dd> </dd>
192<dl class="dl-horizontal">
193<dt>image</dt>
194<dd>the image. </dd>
195
196<dd> </dd>
197<dt>exception</dt>
198<dd>return any errors or warnings in this structure. </dd>
199
200<dd>  </dd>
201</dl>
202<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="OptimizeImageTransparency">OptimizeImageTransparency</a></h2>
203
204<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>
205
206<p>WARNING: This modifies the current images directly, rather than generate a new image sequence.</p>
207
208<p>The format of the OptimizeImageTransperency method is:</p>
209
210<pre class="text">
211void OptimizeImageTransperency(Image *image,ExceptionInfo *exception)
212</pre>
213
214<p>A description of each parameter follows:</p>
215
216<dd>
217</dd>
218
219<dd> </dd>
220<dl class="dl-horizontal">
221<dt>image</dt>
222<dd>the image sequence </dd>
223
224<dd> </dd>
225<dt>exception</dt>
226<dd>return any errors or warnings in this structure. </dd>
227
228<dd>  </dd>
229</dl>
230<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="RemoveDuplicateLayers">RemoveDuplicateLayers</a></h2>
231
232<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>
233
234<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>
235
236<p>The format of the RemoveDuplicateLayers method is:</p>
237
238<pre class="text">
239void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception)
240</pre>
241
242<p>A description of each parameter follows:</p>
243
244<dd>
245</dd>
246
247<dd> </dd>
248<dl class="dl-horizontal">
249<dt>images</dt>
250<dd>the image list </dd>
251
252<dd> </dd>
253<dt>exception</dt>
254<dd>return any errors or warnings in this structure. </dd>
255
256<dd>  </dd>
257</dl>
258<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="RemoveZeroDelayLayers">RemoveZeroDelayLayers</a></h2>
259
260<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>
261
262<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>
263
264<p>No warning will be given if no image was removed because all images had an appropriate non-zero time delay set.</p>
265
266<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>
267
268<p>The format of the RemoveZeroDelayLayers method is:</p>
269
270<pre class="text">
271void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception)
272</pre>
273
274<p>A description of each parameter follows:</p>
275
276<dd>
277</dd>
278
279<dd> </dd>
280<dl class="dl-horizontal">
281<dt>images</dt>
282<dd>the image list </dd>
283
284<dd> </dd>
285<dt>exception</dt>
286<dd>return any errors or warnings in this structure. </dd>
287
288<dd>  </dd>
289</dl>
290<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="CompositeLayers">CompositeLayers</a></h2>
291
292<p>CompositeLayers() compose the source image sequence over the destination image sequence, starting with the current image in both lists.</p>
293
294<p>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>
295
296<p>Composition uses given x and y offsets, as the 'origin' location of the source images virtual canvas (not the real image) allowing you to compose a list of 'layer images' into the destiantioni images.  This makes it well sutiable for directly composing 'Clears Frame Animations' or 'Coaleased Animations' onto a static or other 'Coaleased Animation' destination image list.  GIF disposal handling is not looked at.</p>
297
298<p>Special case:- If one of the image sequences is the last image (just a single image remaining), 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>
299
300<p>In the case of a single destination image (or last image given), that image will ve cloned to match the number of images remaining in the source image list.</p>
301
302<p>This is equivelent to the "-layer Composite" Shell API operator.</p>
303
304
305<p>The format of the CompositeLayers method is:</p>
306
307<pre class="text">
308void CompositeLayers(Image *destination, const CompositeOperator
309compose, Image *source, const ssize_t x_offset, const ssize_t y_offset,
310ExceptionInfo *exception);
311</pre>
312
313<p>A description of each parameter follows:</p>
314
315<dd>
316</dd>
317
318<dd> </dd>
319<dl class="dl-horizontal">
320<dt>destination</dt>
321<dd>the destination images and results </dd>
322
323<dd> </dd>
324<dt>source</dt>
325<dd>source image(s) for the layer composition </dd>
326
327<dd> </dd>
328<dt>compose, x_offset, y_offset</dt>
329<dd> arguments passed on to CompositeImages() </dd>
330
331<dd> </dd>
332<dt>exception</dt>
333<dd>return any errors or warnings in this structure. </dd>
334
335<dd>  </dd>
336</dl>
337<h2><a href="http://www.imagemagick.org/api/MagickCore/layer_8c.html" id="MergeImageLayers">MergeImageLayers</a></h2>
338
339<p>MergeImageLayers() composes all the image layers from the current given image onward to produce a single image of the merged layers.</p>
340
341<p>The inital canvas's size depends on the given LayerMethod, 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>
342
343<p>The format of the MergeImageLayers is:</p>
344
345<pre class="text">
346Image *MergeImageLayers(const Image *image,
347  const LayerMethod method, ExceptionInfo *exception)
348</pre>
349
350<p>A description of each parameter follows:</p>
351
352<dd>
353</dd>
354
355<dd> </dd>
356<dl class="dl-horizontal">
357<dt>image</dt>
358<dd>the image list to be composited together </dd>
359
360<dd> </dd>
361<dt>method</dt>
362<dd>the method of selecting the size of the initial canvas. </dd>
363
364<dd> 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. </dd>
365
366<dd> 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. </dd>
367
368<dd> 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. </dd>
369
370<dd> 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. </dd>
371
372<dd> WARNING: a new image is not returned, the original image sequence page data is modified instead. </dd>
373
374<dd> </dd>
375<dt>exception</dt>
376<dd>return any errors or warnings in this structure. </dd>
377
378<dd>  </dd>
379</dl>
380</div>
381  <footer class="magick-footer">
382    <p><a href="../support.html">Donate</a> •
383     <a href="../sitemap.html">Sitemap</a> •
384    <a href="../links.html">Related</a> •
385    <a href="../architecture.html">Architecture</a>
386</p>
387    <p><a href="layer.html#">Back to top</a> •
388    <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
389    <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
390        <p><small>©  1999-2016 ImageMagick Studio LLC</small></p>
391  </footer>
392</div><!-- /.container -->
393
394  <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
395  <script src="../js/magick.html"></script>
396</div>
397</body>
398</html>
399