blob: 4a389f5ca5bd2ddb9aa856e1be5cc66ef75012ed [file] [log] [blame]
cristy29dc8652015-05-12 16:26:21 +00001<!DOCTYPE html>
cristy44443b92015-05-05 00:06:07 +00002<html lang="en">
cristy06f63f22012-10-31 00:50:07 +00003<head>
Cristy36421ee2015-08-28 11:58:20 -04004
cristy29f2c972015-07-28 13:37:46 +00005 <title>ImageMagick: MagickCore, C API for ImageMagick: Dealing with Image Layers</title>
cristy44443b92015-05-05 00:06:07 +00006 <meta http-equiv="content-type" content="text/html; charset=utf-8">
cristy44443b92015-05-05 00:06:07 +00007 <meta name="application-name" content="ImageMagick">
8 <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.">
9 <meta name="application-url" content="http://www.imagemagick.org">
10 <meta name="generator" content="PHP">
11 <meta name="keywords" content="magickcore, c, api, for, imagemagick:, dealing, with, image, layers, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert">
12 <meta name="rating" content="GENERAL">
13 <meta name="robots" content="INDEX, FOLLOW">
14 <meta name="generator" content="ImageMagick Studio LLC">
15 <meta name="author" content="ImageMagick Studio LLC">
16 <meta name="revisit-after" content="2 DAYS">
17 <meta name="resource-type" content="document">
cristy4e638cd2015-05-07 16:47:40 +000018 <meta name="copyright" content="Copyright (c) 1999-2015 ImageMagick Studio LLC">
cristy44443b92015-05-05 00:06:07 +000019 <meta name="distribution" content="Global">
20 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1">
cristy354f1172015-07-29 14:03:48 +000021 <link rel="icon" href="../images/wand.png">
22 <link rel="shortcut icon" href="../images/wand.ico">
23 <link rel="stylesheet" href="../css/magick.html">
cristy06f63f22012-10-31 00:50:07 +000024</head>
cristy44443b92015-05-05 00:06:07 +000025<body>
cristy06f63f22012-10-31 00:50:07 +000026<div class="main">
cristy44443b92015-05-05 00:06:07 +000027<div class="magick-masthead">
28 <div class="container">
Cristy542697a2015-10-12 20:10:32 -040029 <script async="async" src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3129977114552745" data-ad-slot="6345125851" data-ad-format="auto"></ins>
cristy29f2c972015-07-28 13:37:46 +000030 <script>
Cristy542697a2015-10-12 20:10:32 -040031 (adsbygoogle = window.adsbygoogle || []).push({});
cristy44443b92015-05-05 00:06:07 +000032 </script>
cristy44443b92015-05-05 00:06:07 +000033 <nav class="magick-nav">
cristy2f563d42015-05-06 23:36:51 +000034 <a class="magick-nav-item " href="../index.html">Home</a>
cristyea2793e2015-05-31 16:52:26 +000035 <a class="magick-nav-item " href="../binary-releases.html">Download</a>
cristy38185362015-05-07 20:09:56 +000036 <a class="magick-nav-item " href="../command-line-tools.html">Tools</a>
37 <a class="magick-nav-item " href="../command-line-options.html">Options</a>
cristyea2793e2015-05-31 16:52:26 +000038 <a class="magick-nav-item " href="../resources.html">Resources</a>
39 <a class="magick-nav-item " href="api.html">Develop</a>
cristy5b8fe762015-06-09 16:24:03 +000040 <a class="magick-nav-item " href="http://nextgen.imagemagick.org/script/search.php">Search</a>
cristya1890f02015-05-15 23:32:44 +000041 <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
cristy44443b92015-05-05 00:06:07 +000042 </nav>
43 </div>
44</div>
45<div class="container">
cristy4e638cd2015-05-07 16:47:40 +000046<div class="magick-header">
cristycecc9492015-06-09 16:53:50 +000047<p class="text-center"><a href="layer.html#CoalesceImages">CoalesceImages</a><a href="layer.html#DisposeImages">DisposeImages</a><a href="layer.html#CompareImagesLayers">CompareImagesLayers</a><a href="layer.html#OptimizeImageLayers">OptimizeImageLayers</a><a href="layer.html#OptimizeImagePlusLayers">OptimizeImagePlusLayers</a><a href="layer.html#OptimizeImageTransparency">OptimizeImageTransparency</a><a href="layer.html#RemoveDuplicateLayers">RemoveDuplicateLayers</a><a href="layer.html#RemoveZeroDelayLayers">RemoveZeroDelayLayers</a><a href="layer.html#CompositeLayers">CompositeLayers</a><a href="layer.html#MergeImageLayers">MergeImageLayers</a></p>
cristy06f63f22012-10-31 00:50:07 +000048
cristycecc9492015-06-09 16:53:50 +000049<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="CoalesceImages">CoalesceImages</a></h2>
50
51<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>
52
53<p>The format of the CoalesceImages method is:</p>
54
55<pre class="text">
56Image *CoalesceImages(Image *image,ExceptionInfo *exception)
57</pre>
58
59<p>A description of each parameter follows:</p>
60
61<dd>
62</dd>
63
64<dd> </dd>
65<dl class="dl-horizontal">
66<dt>image</dt>
67<dd>the image sequence. </dd>
68
69<dd> </dd>
70<dt>exception</dt>
71<dd>return any errors or warnings in this structure. </dd>
72
73<dd> </dd>
74</dl>
75<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="DisposeImages">DisposeImages</a></h2>
76
77<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>
78
79<p>The format of the DisposeImages method is:</p>
80
81<pre class="text">
82Image *DisposeImages(Image *image,ExceptionInfo *exception)
83</pre>
84
85<p>A description of each parameter follows:</p>
86
87<dd>
88</dd>
89
90<dd> </dd>
91<dl class="dl-horizontal">
92<dt>images</dt>
93<dd>the image sequence. </dd>
94
95<dd> </dd>
96<dt>exception</dt>
97<dd>return any errors or warnings in this structure. </dd>
98
99<dd> </dd>
100</dl>
101<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="CompareImagesLayers">CompareImagesLayers</a></h2>
102
103<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>
104
105<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>
106
107<p>No GIF dispose methods are applied, so GIF animations must be coalesced before applying this image operator to find differences to them.</p>
108
109<p>The format of the CompareImagesLayers method is:</p>
110
111<pre class="text">
112Image *CompareImagesLayers(const Image *images,
113 const LayerMethod method,ExceptionInfo *exception)
114</pre>
115
116<p>A description of each parameter follows:</p>
117
118<dd>
119</dd>
120
121<dd> </dd>
122<dl class="dl-horizontal">
123<dt>image</dt>
124<dd>the image. </dd>
125
126<dd> </dd>
127<dt>method</dt>
128<dd>the layers type to compare images with. Must be one of... CompareAnyLayer, CompareClearLayer, CompareOverlayLayer. </dd>
129
130<dd> </dd>
131<dt>exception</dt>
132<dd>return any errors or warnings in this structure. </dd>
133
134<dd> </dd>
135</dl>
136<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="OptimizeImageLayers">OptimizeImageLayers</a></h2>
137
138<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>
139
140<p>The format of the OptimizeImageLayers method is:</p>
141
142<pre class="text">
143Image *OptimizeImageLayers(const Image *image,
144 ExceptionInfo *exception)
145</pre>
146
147<p>A description of each parameter follows:</p>
148
149<dd>
150</dd>
151
152<dd> </dd>
153<dl class="dl-horizontal">
154<dt>image</dt>
155<dd>the image. </dd>
156
157<dd> </dd>
158<dt>exception</dt>
159<dd>return any errors or warnings in this structure. </dd>
160
161<dd> </dd>
162</dl>
163<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="OptimizeImagePlusLayers">OptimizeImagePlusLayers</a></h2>
164
165<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>
166
167<p>The format of the OptimizePlusImageLayers method is:</p>
168
169<pre class="text">
170Image *OptimizePlusImageLayers(const Image *image,
171 ExceptionInfo *exception)
172</pre>
173
174<p>A description of each parameter follows:</p>
175
176<dd>
177</dd>
178
179<dd> </dd>
180<dl class="dl-horizontal">
181<dt>image</dt>
182<dd>the image. </dd>
183
184<dd> </dd>
185<dt>exception</dt>
186<dd>return any errors or warnings in this structure. </dd>
187
188<dd> </dd>
189</dl>
190<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="OptimizeImageTransparency">OptimizeImageTransparency</a></h2>
191
192<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>
193
194<p>WARNING: This modifies the current images directly, rather than generate a new image sequence.</p>
195
196<p>The format of the OptimizeImageTransperency method is:</p>
197
198<pre class="text">
199void OptimizeImageTransperency(Image *image,ExceptionInfo *exception)
200</pre>
201
202<p>A description of each parameter follows:</p>
203
204<dd>
205</dd>
206
207<dd> </dd>
208<dl class="dl-horizontal">
209<dt>image</dt>
210<dd>the image sequence </dd>
211
212<dd> </dd>
213<dt>exception</dt>
214<dd>return any errors or warnings in this structure. </dd>
215
216<dd> </dd>
217</dl>
218<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="RemoveDuplicateLayers">RemoveDuplicateLayers</a></h2>
219
220<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>
221
222<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>
223
224<p>The format of the RemoveDuplicateLayers method is:</p>
225
226<pre class="text">
227void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception)
228</pre>
229
230<p>A description of each parameter follows:</p>
231
232<dd>
233</dd>
234
235<dd> </dd>
236<dl class="dl-horizontal">
237<dt>images</dt>
238<dd>the image list </dd>
239
240<dd> </dd>
241<dt>exception</dt>
242<dd>return any errors or warnings in this structure. </dd>
243
244<dd> </dd>
245</dl>
246<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="RemoveZeroDelayLayers">RemoveZeroDelayLayers</a></h2>
247
248<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>
249
250<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>
251
252<p>No warning will be given if no image was removed because all images had an appropriate non-zero time delay set.</p>
253
254<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>
255
256<p>The format of the RemoveZeroDelayLayers method is:</p>
257
258<pre class="text">
259void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception)
260</pre>
261
262<p>A description of each parameter follows:</p>
263
264<dd>
265</dd>
266
267<dd> </dd>
268<dl class="dl-horizontal">
269<dt>images</dt>
270<dd>the image list </dd>
271
272<dd> </dd>
273<dt>exception</dt>
274<dd>return any errors or warnings in this structure. </dd>
275
276<dd> </dd>
277</dl>
278<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="CompositeLayers">CompositeLayers</a></h2>
279
280<p>CompositeLayers() compose the source image sequence over the destination image sequence, starting with the current image in both lists.</p>
281
282<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>
283
284<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>
285
286<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>
287
288<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>
289
290<p>This is equivelent to the "-layer Composite" Shell API operator.</p>
291
292
293<p>The format of the CompositeLayers method is:</p>
294
295<pre class="text">
296void CompositeLayers(Image *destination, const CompositeOperator
297compose, Image *source, const ssize_t x_offset, const ssize_t y_offset,
298ExceptionInfo *exception);
299</pre>
300
301<p>A description of each parameter follows:</p>
302
303<dd>
304</dd>
305
306<dd> </dd>
307<dl class="dl-horizontal">
308<dt>destination</dt>
309<dd>the destination images and results </dd>
310
311<dd> </dd>
312<dt>source</dt>
313<dd>source image(s) for the layer composition </dd>
314
315<dd> </dd>
316<dt>compose, x_offset, y_offset</dt>
317<dd> arguments passed on to CompositeImages() </dd>
318
319<dd> </dd>
320<dt>exception</dt>
321<dd>return any errors or warnings in this structure. </dd>
322
323<dd> </dd>
324</dl>
325<h2><a href="http://nextgen.imagemagick.org/api/MagickCore/layer_8c.html" id="MergeImageLayers">MergeImageLayers</a></h2>
326
327<p>MergeImageLayers() composes all the image layers from the current given image onward to produce a single image of the merged layers.</p>
328
329<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>
330
331<p>The format of the MergeImageLayers is:</p>
332
333<pre class="text">
334Image *MergeImageLayers(const Image *image,
335 const LayerMethod method, ExceptionInfo *exception)
336</pre>
337
338<p>A description of each parameter follows:</p>
339
340<dd>
341</dd>
342
343<dd> </dd>
344<dl class="dl-horizontal">
345<dt>image</dt>
346<dd>the image list to be composited together </dd>
347
348<dd> </dd>
349<dt>method</dt>
350<dd>the method of selecting the size of the initial canvas. </dd>
351
352<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>
353
354<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>
355
356<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>
357
358<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>
359
360<dd> WARNING: a new image is not returned, the original image sequence page data is modified instead. </dd>
361
362<dd> </dd>
363<dt>exception</dt>
364<dd>return any errors or warnings in this structure. </dd>
365
366<dd> </dd>
367</dl>
cristy06f63f22012-10-31 00:50:07 +0000368</div>
cristy44443b92015-05-05 00:06:07 +0000369 <footer class="magick-footer">
cristy29f2c972015-07-28 13:37:46 +0000370 <p><a href="../support.html">Donate</a>
371 <a href="../sitemap.html">Sitemap</a>
cristy38185362015-05-07 20:09:56 +0000372 <a href="../links.html">Related</a>
cristy29f2c972015-07-28 13:37:46 +0000373 <a href="../architecture.html">Architecture</a>
cristy44443b92015-05-05 00:06:07 +0000374</p>
375 <p><a href="layer.html#">Back to top</a>
cristyea2793e2015-05-31 16:52:26 +0000376 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
cristy5b8fe762015-06-09 16:24:03 +0000377 <a href="http://nextgen.imagemagick.org/script/contact.php">Contact Us</a></p>
Cristy36421ee2015-08-28 11:58:20 -0400378 <p><small>© 1999-2015 ImageMagick Studio LLC</small></p>
cristy44443b92015-05-05 00:06:07 +0000379 </footer>
380</div><!-- /.container -->
cristy06f63f22012-10-31 00:50:07 +0000381
Cristy542697a2015-10-12 20:10:32 -0400382 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
cristy29f2c972015-07-28 13:37:46 +0000383 <script src="http://nextgen.imagemagick.org/js/magick.html"></script>
cristy44cbd482013-08-04 20:53:36 +0000384</div>
cristy06f63f22012-10-31 00:50:07 +0000385</body>
cristy5a367e42015-05-05 12:39:18 +0000386</html>