1 2 3 4 5 <!DOCTYPE html> 6 <html lang="en"> 7 <head> 8 <meta charset="utf-8" /> 9 <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no" /> 10 <title>MagickCore, C API: Dealing with Image Layers @ ImageMagick</title> 11 <meta name="application-name" content="ImageMagick" /> 12 <meta name="description" content="Use ImageMagick to create, edit, compose, or convert bitmap images. You can resize your image, crop it, change its shades and colors, add captions, among other operations." /> 13 <meta name="application-url" content="https://imagemagick.org" /> 14 <meta name="generator" content="PHP" /> 15 <meta name="keywords" content="magickcore, c, api:, dealing, with, image, layers, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert" /> 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-2017 ImageMagick Studio LLC" /> 23 <meta name="distribution" content="Global" /> 24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" /> 25 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" /> 26 <link href="layer.html" rel="canonical" /> 27 <link href="../../images/wand.png" rel="icon" /> 28 <link href="../../images/wand.ico" rel="shortcut icon" /> 29 <link href="../assets/magick.css" rel="stylesheet" /> 30 </head> 31 <body> 32 <header> 33 <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark"> 34 <a class="navbar-brand" href="../../"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../../images/wand.ico"/></a> 35 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation"> 36 <span class="navbar-toggler-icon"></span> 37 </button> 38 39 <div class="navbar-collapse collapse" id="navbarsMagick" style=""> 40 <ul class="navbar-nav mr-auto"> 41 <li class="nav-item "> 42 <a class="nav-link" href="quantize.html">Home <span class="sr-only">(current)</span></a> 43 </li> 44 <li class="nav-item "> 45 <a class="nav-link" href="../../www/download.html">Download</a> 46 </li> 47 <li class="nav-item "> 48 <a class="nav-link" href="../../www/command-line-tools.html">Tools</a> 49 </li> 50 <li class="nav-item "> 51 <a class="nav-link" href="../../www/command-line-processing.html">Command-line</a> 52 </li> 53 <li class="nav-item "> 54 <a class="nav-link" href="../../www/resources.html">Resources</a> 55 </li> 56 <li class="nav-item "> 57 <a class="nav-link" href="../../www/develop.html">Develop</a> 58 </li> 59 <li class="nav-item"> 60 <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a> 61 </li> 62 </ul> 63 <form class="form-inline my-2 my-lg-0" action="https://imagemagick.org/script/search.php"> 64 <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search"> 65 <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button> 66 </form> 67 </div> 68 </nav> 69 <div class="container"> 70 <script async="async" src="https://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" 71 style="display:block" 72 data-ad-client="ca-pub-3129977114552745" 73 data-ad-slot="6345125851" 74 data-ad-format="auto"></ins> 75 <script> 76 (adsbygoogle = window.adsbygoogle || []).push({}); 77 </script> 78 79 </div> 80 </header> 81 <main class="container"> 82 <div class="magick-template"> 83 <div class="magick-header"> 84 <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> 85 86 <h2><a href="../../api/MagickCore/layer_8c.html" id="CoalesceImages">CoalesceImages</a></h2> 87 88 <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> 89 90 <p>The format of the CoalesceImages method is:</p> 91 92 <pre class="text"> 93 Image *CoalesceImages(Image *image,ExceptionInfo *exception) 94 </pre> 95 96 <p>A description of each parameter follows:</p> 97 98 <dd> 99 </dd> 100 101 <dd> </dd> 102 <dl class="dl-horizontal"> 103 <dt>image</dt> 104 <dd>the image sequence. </dd> 105 106 <dd> </dd> 107 <dt>exception</dt> 108 <dd>return any errors or warnings in this structure. </dd> 109 110 <dd> </dd> 111 </dl> 112 <h2><a href="../../api/MagickCore/layer_8c.html" id="DisposeImages">DisposeImages</a></h2> 113 114 <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> 115 116 <p>The format of the DisposeImages method is:</p> 117 118 <pre class="text"> 119 Image *DisposeImages(Image *image,ExceptionInfo *exception) 120 </pre> 121 122 <p>A description of each parameter follows:</p> 123 124 <dd> 125 </dd> 126 127 <dd> </dd> 128 <dl class="dl-horizontal"> 129 <dt>images</dt> 130 <dd>the image sequence. </dd> 131 132 <dd> </dd> 133 <dt>exception</dt> 134 <dd>return any errors or warnings in this structure. </dd> 135 136 <dd> </dd> 137 </dl> 138 <h2><a href="../../api/MagickCore/layer_8c.html" id="CompareImagesLayers">CompareImagesLayers</a></h2> 139 140 <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> 141 142 <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> 143 144 <p>No GIF dispose methods are applied, so GIF animations must be coalesced before applying this image operator to find differences to them.</p> 145 146 <p>The format of the CompareImagesLayers method is:</p> 147 148 <pre class="text"> 149 Image *CompareImagesLayers(const Image *images, 150 const LayerMethod method,ExceptionInfo *exception) 151 </pre> 152 153 <p>A description of each parameter follows:</p> 154 155 <dd> 156 </dd> 157 158 <dd> </dd> 159 <dl class="dl-horizontal"> 160 <dt>image</dt> 161 <dd>the image. </dd> 162 163 <dd> </dd> 164 <dt>method</dt> 165 <dd>the layers type to compare images with. Must be one of... CompareAnyLayer, CompareClearLayer, CompareOverlayLayer. </dd> 166 167 <dd> </dd> 168 <dt>exception</dt> 169 <dd>return any errors or warnings in this structure. </dd> 170 171 <dd> </dd> 172 </dl> 173 <h2><a href="../../api/MagickCore/layer_8c.html" id="OptimizeImageLayers">OptimizeImageLayers</a></h2> 174 175 <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> 176 177 <p>The format of the OptimizeImageLayers method is:</p> 178 179 <pre class="text"> 180 Image *OptimizeImageLayers(const Image *image, 181 ExceptionInfo *exception) 182 </pre> 183 184 <p>A description of each parameter follows:</p> 185 186 <dd> 187 </dd> 188 189 <dd> </dd> 190 <dl class="dl-horizontal"> 191 <dt>image</dt> 192 <dd>the image. </dd> 193 194 <dd> </dd> 195 <dt>exception</dt> 196 <dd>return any errors or warnings in this structure. </dd> 197 198 <dd> </dd> 199 </dl> 200 <h2><a href="../../api/MagickCore/layer_8c.html" id="OptimizeImagePlusLayers">OptimizeImagePlusLayers</a></h2> 201 202 <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> 203 204 <p>The format of the OptimizePlusImageLayers method is:</p> 205 206 <pre class="text"> 207 Image *OptimizePlusImageLayers(const Image *image, 208 ExceptionInfo *exception) 209 </pre> 210 211 <p>A description of each parameter follows:</p> 212 213 <dd> 214 </dd> 215 216 <dd> </dd> 217 <dl class="dl-horizontal"> 218 <dt>image</dt> 219 <dd>the image. </dd> 220 221 <dd> </dd> 222 <dt>exception</dt> 223 <dd>return any errors or warnings in this structure. </dd> 224 225 <dd> </dd> 226 </dl> 227 <h2><a href="../../api/MagickCore/layer_8c.html" id="OptimizeImageTransparency">OptimizeImageTransparency</a></h2> 228 229 <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> 230 231 <p>WARNING: This modifies the current images directly, rather than generate a new image sequence.</p> 232 233 <p>The format of the OptimizeImageTransperency method is:</p> 234 235 <pre class="text"> 236 void OptimizeImageTransperency(Image *image,ExceptionInfo *exception) 237 </pre> 238 239 <p>A description of each parameter follows:</p> 240 241 <dd> 242 </dd> 243 244 <dd> </dd> 245 <dl class="dl-horizontal"> 246 <dt>image</dt> 247 <dd>the image sequence </dd> 248 249 <dd> </dd> 250 <dt>exception</dt> 251 <dd>return any errors or warnings in this structure. </dd> 252 253 <dd> </dd> 254 </dl> 255 <h2><a href="../../api/MagickCore/layer_8c.html" id="RemoveDuplicateLayers">RemoveDuplicateLayers</a></h2> 256 257 <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> 258 259 <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> 260 261 <p>The format of the RemoveDuplicateLayers method is:</p> 262 263 <pre class="text"> 264 void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception) 265 </pre> 266 267 <p>A description of each parameter follows:</p> 268 269 <dd> 270 </dd> 271 272 <dd> </dd> 273 <dl class="dl-horizontal"> 274 <dt>images</dt> 275 <dd>the image list </dd> 276 277 <dd> </dd> 278 <dt>exception</dt> 279 <dd>return any errors or warnings in this structure. </dd> 280 281 <dd> </dd> 282 </dl> 283 <h2><a href="../../api/MagickCore/layer_8c.html" id="RemoveZeroDelayLayers">RemoveZeroDelayLayers</a></h2> 284 285 <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> 286 287 <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> 288 289 <p>No warning will be given if no image was removed because all images had an appropriate non-zero time delay set.</p> 290 291 <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> 292 293 <p>The format of the RemoveZeroDelayLayers method is:</p> 294 295 <pre class="text"> 296 void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception) 297 </pre> 298 299 <p>A description of each parameter follows:</p> 300 301 <dd> 302 </dd> 303 304 <dd> </dd> 305 <dl class="dl-horizontal"> 306 <dt>images</dt> 307 <dd>the image list </dd> 308 309 <dd> </dd> 310 <dt>exception</dt> 311 <dd>return any errors or warnings in this structure. </dd> 312 313 <dd> </dd> 314 </dl> 315 <h2><a href="../../api/MagickCore/layer_8c.html" id="CompositeLayers">CompositeLayers</a></h2> 316 317 <p>CompositeLayers() compose the source image sequence over the destination image sequence, starting with the current image in both lists.</p> 318 319 <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> 320 321 <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> 322 323 <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> 324 325 <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> 326 327 <p>This is equivelent to the "-layer Composite" Shell API operator.</p> 328 329 330 <p>The format of the CompositeLayers method is:</p> 331 332 <pre class="text"> 333 void CompositeLayers(Image *destination, const CompositeOperator 334 compose, Image *source, const ssize_t x_offset, const ssize_t y_offset, 335 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>destination</dt> 346 <dd>the destination images and results </dd> 347 348 <dd> </dd> 349 <dt>source</dt> 350 <dd>source image(s) for the layer composition </dd> 351 352 <dd> </dd> 353 <dt>compose, x_offset, y_offset</dt> 354 <dd> arguments passed on to CompositeImages() </dd> 355 356 <dd> </dd> 357 <dt>exception</dt> 358 <dd>return any errors or warnings in this structure. </dd> 359 360 <dd> </dd> 361 </dl> 362 <h2><a href="../../api/MagickCore/layer_8c.html" id="MergeImageLayers">MergeImageLayers</a></h2> 363 364 <p>MergeImageLayers() composes all the image layers from the current given image onward to produce a single image of the merged layers.</p> 365 366 <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> 367 368 <p>The format of the MergeImageLayers is:</p> 369 370 <pre class="text"> 371 Image *MergeImageLayers(const Image *image, 372 const LayerMethod method, ExceptionInfo *exception) 373 </pre> 374 375 <p>A description of each parameter follows:</p> 376 377 <dd> 378 </dd> 379 380 <dd> </dd> 381 <dl class="dl-horizontal"> 382 <dt>image</dt> 383 <dd>the image list to be composited together </dd> 384 385 <dd> </dd> 386 <dt>method</dt> 387 <dd>the method of selecting the size of the initial canvas. </dd> 388 389 <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> 390 391 <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> 392 393 <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> 394 395 <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> 396 397 <dd> WARNING: a new image is not returned, the original image sequence page data is modified instead. </dd> 398 399 <dd> </dd> 400 <dt>exception</dt> 401 <dd>return any errors or warnings in this structure. </dd> 402 403 <dd> </dd> 404 </dl> 405 </div> 406 </div> 407 </main><!-- /.container --> 408 <footer class="magick-footer"> 409 <p><a href="../../www/security-policy.html">Security</a> 410 <a href="../../www/architecture.html">Architecture</a> 411 <a href="../../www/links.html">Related</a> 412 <a href="../../www/sitemap.html">Sitemap</a> 413 414 <a href="layer.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../../images/wand.ico"/></a> 415 416 <a href="http://pgp.mit.edu/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 417 <a href="../../www/support.html">Donate</a> 418 <a href="../../www/contact.html">Contact Us</a> 419 <br/> 420 <small> 1999-2019 ImageMagick Studio LLC</small></p> 421 </footer> 422 423 <!-- Javascript assets --> 424 <script src="../assets/magick.js" crossorigin="anonymous"></script> 425 <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>')</script> 426 </body> 427 </html> 428 <!-- Magick Cache 30th December 2018 12:31 -->