blob: f074a8f49a81dcc5c66a15abfe71da36dbbcb969 [file] [log] [blame]
cristybc9539a2010-08-16 18:06:20 +00001
cristydcca3fa2010-12-29 21:50:07 +00002<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
cristy2bd2a982011-02-15 00:52:58 +00004<html version="-//W3C//DTD XHTML 1.1//EN"
5 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
6 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7 xsi:schemaLocation="http://www.w3.org/1999/xhtml
8 http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
cristybc9539a2010-08-16 18:06:20 +00009<head>
10 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
cristy1efc1ab2011-08-01 14:47:02 +000011 <meta name="google-site-verification" content="MxsMq6bdLOx0KSuz1MY6yG9ZTIJ7_7DVRfl5NCAT5Yg"/>
cristydcca3fa2010-12-29 21:50:07 +000012 <title>ImageMagick: Alpha Compositing</title>
cristybc9539a2010-08-16 18:06:20 +000013 <meta http-equiv="Content-Language" content="en-US"/>
14 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
15 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
16 <meta name="Application-name" content="ImageMagick"/>
cristye6e84152011-06-06 14:16:49 +000017 <meta name="Description" content="Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition resize, rotate, shear, distort and transform images automagically."/>
cristybc9539a2010-08-16 18:06:20 +000018 <meta name="Application-url" content="http://www.imagemagick.org"/>
19 <meta name="Generator" content="PHP"/>
cristyeed6cb62012-01-28 19:38:34 +000020 <meta name="Keywords" content="alpha, compositing, ImageMagick, PerlMagick, image processing, OpenMP, software development library, image, photo, software, Magick++, MagickWand"/>
cristybc9539a2010-08-16 18:06:20 +000021 <meta name="Rating" content="GENERAL"/>
22 <meta name="Robots" content="INDEX, FOLLOW"/>
23 <meta name="Generator" content="ImageMagick Studio LLC"/>
24 <meta name="Author" content="ImageMagick Studio LLC"/>
25 <meta name="Revisit-after" content="2 DAYS"/>
26 <meta name="Resource-type" content="document"/>
cristy1454be72011-12-19 01:52:48 +000027 <meta name="Copyright" content="Copyright (c) 1999-2012 ImageMagick Studio LLC"/>
cristybc9539a2010-08-16 18:06:20 +000028 <meta name="Distribution" content="Global"/>
cristydcca3fa2010-12-29 21:50:07 +000029 <link rel="icon" href="../images/wand.png"/>
cristybc9539a2010-08-16 18:06:20 +000030 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"/>
cristy29c5c992011-06-25 13:58:49 +000031 <link rel="canonical" href="http://www.imagemagick.org" />
cristybc9539a2010-08-16 18:06:20 +000032 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
cristyeed6cb62012-01-28 19:38:34 +000033 <!-- Add jQuery library -->
34 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
35
36 <!-- Optionaly include easing and/or mousewheel plugins -->
37 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.easing-1.3.pack.js"></script>
38 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>
39
40 <!-- Add fancyBox -->
41 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/jquery.fancybox.css?v=2.0.3" type="text/css" media="screen" />
42 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.fancybox.pack.js?v=2.0.3"></script>
43
44 <!-- Optionaly include button and/or thumbnail helpers -->
45 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.css?v=2.0.3" type="text/css" media="screen" />
46 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.js?v=2.0.3"></script>
47
48 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.css?v=2.0.3" type="text/css" media="screen" />
49 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.js?v=2.0.3"></script>
50 <script type="text/javascript">
51 $(document).ready(function() {
52 $(".fancybox").fancybox();
53 });
54 </script>
55 <!-- ImageMagick style -->
cristy7a40ba82011-01-08 20:31:18 +000056 <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
cristybc9539a2010-08-16 18:06:20 +000057 <style type="text/css" media="all">
58 @import url("../www/magick.css");
59 </style>
60</head>
61
62<body id="www-imagemagick-org">
63<div class="titlebar">
cristyb52981c2011-03-19 17:09:31 +000064<div style="margin: 17px auto; float: left;">
65 <script type="text/javascript">
66 <!--
67 google_ad_client = "pub-3129977114552745";
68 google_ad_slot = "5439289906";
69 google_ad_width = 728;
70 google_ad_height = 90;
71 //-->
72 </script>
73 <script type="text/javascript"
74 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
75 </script>
76</div>
cristybc9539a2010-08-16 18:06:20 +000077<a href="http://www.imagemagick.org/discourse-server/">
cristyaf8d6652011-02-04 21:57:45 +000078 <img src="../images/logo.jpg"
79 alt="ImageMagick Logo"
cristy178edaf2011-01-23 03:42:39 +000080 style="width: 123px; height: 118px; border: 0px; float: right;" /></a>
cristybc9539a2010-08-16 18:06:20 +000081<a href="../index.html">
cristyaf8d6652011-02-04 21:57:45 +000082 <img src="../images/sprite.jpg"
83 alt="ImageMagick Sprite"
cristybc9539a2010-08-16 18:06:20 +000084 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
85</div>
86
87<div class="westbar">
88
89<div class="menu">
90 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
91</div>
cristybc9539a2010-08-16 18:06:20 +000092<div class="menu">
93 <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
94</div>
95<div class="sub">
96 <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
97</div>
98<div class="sub">
99 <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
100</div>
101<div class="sub">
cristye6e84152011-06-06 14:16:49 +0000102 <a title="Binary Release: iOS" href="../www/binary-releases.html#iOS">iOS</a>
cristyda16f162011-02-19 23:52:17 +0000103</div>
104<div class="sub">
cristybc9539a2010-08-16 18:06:20 +0000105 <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
106</div>
107<div class="sep"></div>
108<div class="menu">
109 <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
110</div>
111<div class="sub">
112 <a title="Command-line Tools: Processing" href="../www/command-line-processing.html">Processing</a>
113</div>
114<div class="sub">
115 <a title="Command-line Tools: Options" href="../www/command-line-options.html">Options</a>
116</div>
117<div class="sub">
118 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
119</div>
120<div class="menu">
121 <a title="Program Interfaces" href="../www/api.html">Program Interfaces</a>
122</div>
123<div class="sub">
124 <a title="Program Interface: MagickWand" href="../www/magick-wand.html">MagickWand</a>
125</div>
126<div class="sub">
127 <a title="Program Interface: MagickCore" href="../www/magick-core.html">MagickCore</a>
128</div>
129<div class="sub">
130 <a title="Program Interface: PerlMagick" href="../www/perl-magick.html">PerlMagick</a>
131</div>
132<div class="sub">
cristydcca3fa2010-12-29 21:50:07 +0000133 <a title="Program Interface: Magick++" href="../www/magick++.html">Magick++</a>
cristybc9539a2010-08-16 18:06:20 +0000134</div>
135<div class="sep"></div>
136<div class="menu">
137 <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
138</div>
139<div class="sub">
140 <a title="Install from Source: Unix" href="../www/install-source.html#unix">Unix</a>
141</div>
142<div class="sub">
143 <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
144 </div>
145<div class="menu">
146 <a title="Resources" href="../www/resources.html">Resources</a>
147</div>
148<div class="menu">
149 <a title="Architecture" href="../www/architecture.html">Architecture</a>
150</div>
151<div class="menu">
152 <a title="Download" href="../www/download.html">Download</a>
153</div>
154<div class="sep"></div>
155<div class="menu">
cristy52923442011-01-15 22:54:31 +0000156 <a title="Search" href="../www/search.html">Search</a>
cristybc9539a2010-08-16 18:06:20 +0000157</div>
158<div class="sep"></div>
159<div class="menu">
cristydcca3fa2010-12-29 21:50:07 +0000160 <a title="Site Map" href="../www/sitemap.html">Site Map</a>
cristybc9539a2010-08-16 18:06:20 +0000161</div>
162<div class="sub">
cristydcca3fa2010-12-29 21:50:07 +0000163 <a title="Site Map: Links" href="../www/links.html">Links</a>
cristybc9539a2010-08-16 18:06:20 +0000164</div>
165<div class="sep"></div>
cristyeed6cb62012-01-28 19:38:34 +0000166<div class="menu">
cristy10549a12011-05-15 19:04:46 +0000167 <a rel="follow" title="Sponsors" href="../www/sponsors.html">Sponsors:</a>
cristybc9539a2010-08-16 18:06:20 +0000168
cristyeed6cb62012-01-28 19:38:34 +0000169 <a href="http://www.networkredux.com"> <img src="../images/networkredux.png" width="140" height="31" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a>
170 <a href="http://www.dinodirect.com/ipads-tablets/"> <img src="../images/dino-direct.jpg" width="140" height="90" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a><!-- 201204010120 mickey@163... -->
cristybc9539a2010-08-16 18:06:20 +0000171<div class="sponsbox">
cristyeed6cb62012-01-28 19:38:34 +0000172<div class="sponsor">
173 <a rel="follow" title="Android Tablet" href="http://www.dinodirect.com/ipads-tablets/">Android Tablet</a><!-- 201204010120 mickey@163... -->
cristy81492d62011-06-07 16:41:42 +0000174</div>
cristyeed6cb62012-01-28 19:38:34 +0000175<div class="sponsor">
cristyaf894d72011-08-06 23:03:10 +0000176 <a rel="follow" title="Sponsor: Web Hosting" href="http://www.micfo.com">Web Hosting</a><!-- 209901010090s golestan -->
cristy1efc1ab2011-08-01 14:47:02 +0000177</div>
cristyeed6cb62012-01-28 19:38:34 +0000178<div class="sponsor">
179 <a rel="follow" title="Sponsor: Autos Part" href="http://www.pkwteile.de/autoteile">Autos Part</a><!-- 201203010270 info@pkwte... -->
cristy84134182011-06-15 22:59:00 +0000180</div>
cristyeed6cb62012-01-28 19:38:34 +0000181<div class="sponsor">
182 <a rel="follow" title="Sponsor: Web Site Hosting" href="http://webhostinggeeks.com">Web Site Hosting</a><!-- 201302010900 funds@enmob... -->
cristy81492d62011-06-07 16:41:42 +0000183</div>
cristyeed6cb62012-01-28 19:38:34 +0000184<div class="sponsor">
185 <a rel="follow" title="Sponsor: Tenant Check" href="http://www.rentmethod.com/">Tenant Check</a><!-- 201203010090 chris@rentm... -->
cristyba1758d2011-06-03 01:29:12 +0000186</div>
cristyeed6cb62012-01-28 19:38:34 +0000187<div class="sponsor">
188 <a rel="follow" title="Sponsor: VPS" href="http://www.interdominios.com/vps">VPS</a><!-- 201204010090 barsh@inter... -->
cristyaf894d72011-08-06 23:03:10 +0000189</div>
cristyeed6cb62012-01-28 19:38:34 +0000190<div class="sponsor">
191 <a rel="follow" title="Sponsor: Premium Quality Stock Photos" href="http://www.f1online.pro/en/">Premium Quality Stock Photos</a><!-- 2012080100540 ... -->
192</div>
193<div class="sponsor">
194 <a rel="follow" title="Sponsor: Search engine optimisation" href="http://www.seomoves.com.au">Search engine optimisation</a><!-- 201301010090s jen@seo lowprofilelinks -->
195</div>
196<div class="sponsor">
197 <a rel="follow" title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 2012070100250 ... -->
198</div>
199<div class="sponsor">
200 <a rel="follow" title="Sponsor: Managed Server" href="http://www.robhost.de">Managed Server</a><!-- 201210010720 klikics... -->
201</div>
202<div class="sponsor">
203 <a rel="follow" title="Sponsor: Stock Photography" href="http://www.fotosearch.com/">Stock Photography</a><!-- 2012040100250 ... -->
204</div>
205<div class="sponsor">
206 <a rel="follow" title="Sponsor: Autoteile" href="http://www.q11-shop.de">Autoteile</a><!-- 201205010540 suvalj -->
207</div>
208<div class="sponsor">
209 <a rel="follow" title="Sponsor: Royalty Free Stock Images" href="http://www.canstockphoto.com/">Royalty Free Stock Images</a><!-- 2012050100360 support@can -->
210</div>
211<div class="sponsor">
cristyba1758d2011-06-03 01:29:12 +0000212 <a rel="follow" title="Sponsor: Web Hosting Reviews" href="http://www.webhostingsecretrevealed.com">Web Hosting Secret Revealed</a><!-- 201204010540 iamchee jerry -->
213</div>
cristyeed6cb62012-01-28 19:38:34 +0000214<div class="sponsor">
cristy10549a12011-05-15 19:04:46 +0000215 <a rel="follow" title="Sponsor: Druckerei" href="http://www.allesdruck.de">Druckerei</a><!-- 201303011500 r.leo -->
cristy4c54bbb2011-03-17 13:53:13 +0000216</div>
cristyeed6cb62012-01-28 19:38:34 +0000217<div class="sponsor">
218 <a rel="follow" title="Sponsor: Photo Sharing Websites" href="http://www.zoofoo.com">Photo Sharing Websites</a><!-- 2012050100150 dancu@dans...-->
cristy4bf6e232011-05-21 01:43:33 +0000219</div>
cristyeed6cb62012-01-28 19:38:34 +0000220<div class="sponsor">
221 <a rel="follow" title="Sponsor: Schlüsseldienst Berlin BSD" href="http://www.schluesseldienst-berlin.de">Schlüsseldienst Berlin BSD</a><!-- 2012050100025 info@schlues-->
cristyec6b4752011-01-08 03:16:23 +0000222</div>
cristybc9539a2010-08-16 18:06:20 +0000223</div>
224</div>
225</div>
226
227<div class="eastbar">
cristy29c5c992011-06-25 13:58:49 +0000228 <div class="g-plusone" data-size="standard" data-count="false"></div>
cristyeed6cb62012-01-28 19:38:34 +0000229 <script type="text/javascript">
230 window.___gcfg = {
231 lang: 'en-US'
232 };
233
234 (function() {
235 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
236 po.src = 'https://apis.google.com/js/plusone.js';
237 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
238 })();
239 </script>
cristy29c5c992011-06-25 13:58:49 +0000240</div>
cristybc9539a2010-08-16 18:06:20 +0000241
242<div class="main">
243
cristydcca3fa2010-12-29 21:50:07 +0000244<h1>ImageMagick Image Composition</h1>
cristyabd337d2010-08-17 01:06:59 +0000245<p>This page descibed the Image composition methods that is used to define how
246two images should be merged together in various image operations. For the
247Command Line API it is typically set using the <A
248HREF="../www/command-line-options.html#compose" >-compose</A> setting option. </p>
249
250
cristybc9539a2010-08-16 18:06:20 +0000251<p>The description of composition uses abstract terminology in order to allow
252the description to be more precise, while avoiding constant values which are
253specific to a particular build configuration. Each image pixel is represented
254by red, green, and blue levels (which are equal for a gray pixel). The
255build-dependent value <em class="QR">QuantumRange</em> is the maximum integral
256value which may be stored, per pixel, in the red, green, or blue channels of
257the image. Each image pixel may also optionally (if the image matte channel is
258enabled) have an associated level of opacity, ranging from <em>opaque</em> to
259<em>transparent</em>, which may be used to determine the influence of the pixel
260color when compositing the pixel with another image pixel. If the image matte
261channel is disabled, then all pixels in the image are treated as opaque. The
262color of an opaque pixel is fully visible while the color of a transparent
263pixel color is entirely absent (pixel color is ignored).</p>
264
265<p>By definition, raster images have a rectangular shape. All image rows are of
266equal length, as are all image columns. By treating the alpha channel as a
267visual "mask" the rectangular image may be given a "shape" by treating the
268alpha channel as a cookie-cutter for the image. This is done by setting the
269pixels within the shape to be opaque, with pixels outside the shape set as
270transparent. Pixels on the boundary of the shape may be between opaque and
271transparent in order to provide antialiasing (visually smooth edges). The
272description of the composition operators use this concept of image "shape" in
273order to make the description of the operators easier to understand. While it
274is convenient to describe the operators in terms of "shapes" they are by no
275means limited to mask-style operations since they are based on continuous
276floating-point mathematics rather than simple boolean operations.</p>
277
278<p>The following alpha blending (Duff-Porter) compose methods are available:</p>
279
280<table class="doc">
281 <tbody>
282 <tr valign="top">
283 <th align="left" style="width: 8%">Method</th>
284 <th align="left">Description</th>
285 </tr>
286
287 <tr valign="top">
288 <td valign="top">clear</td>
289 <td valign="top">Both the color and the alpha of the destination are
290 cleared. Neither the source nor the destination are used (except for
291 destinations size and other meta-data which is always preserved.</td>
292 </tr>
293
294 <tr valign="top">
295 <td valign="top">src</td>
296 <td valign="top">The source is copied to the destination. The destination
297 is not used as input, though it is cleared.</td>
298 </tr>
299
300 <tr valign="top">
301 <td valign="top">dst</td>
302 <td valign="top">The destination is left untouched. The source image is
303 completely ignored.</td>
304 </tr>
305
306 <tr valign="top">
307 <td valign="top">src-over</td>
308 <td valign="top">The source is composited over the destination. this is
309 the default alpha blending compose method, when neither the compose
310 setting is set, nor is set in the image meta-data.</td>
311 </tr>
312
313 <tr valign="top">
314 <td valign="top">dst-over</td>
315 <td valign="top">The destination is composited over the source and the
316 result replaces the destination.</td>
317 </tr>
318
319 <tr valign="top">
320 <td valign="top">src-in</td>
321 <td valign="top">The part of the source lying inside of the destination
322 replaces the destination.</td>
323 </tr>
324
325 <tr valign="top">
326 <td valign="top">dst-in</td>
327 <td valign="top">The part of the destination lying inside of the source
328 replaces the destination. Areas not overlaid are cleared.</td>
329 </tr>
330
331 <tr valign="top">
332 <td valign="top">src-out</td>
333 <td valign="top">The part of the source lying outside of the destination
334 replaces the destination.</td>
335 </tr>
336
337 <tr valign="top">
338 <td valign="top">dst-out</td>
339 <td valign="top">The part of the destination lying outside of the source
340 replaces the destination.</td>
341 </tr>
342
343 <tr valign="top">
344 <td valign="top">src-atop</td>
345 <td valign="top">The part of the source lying inside of the destination is
346 composited onto the destination.</td>
347 </tr>
348
349 <tr valign="top">
350 <td valign="top">dst-atop</td>
351 <td valign="top">The part of the destination lying inside of the source is
352 composited over the source and replaces the destination. Areas not
353 overlaid are cleared. </td>
354 </tr>
355
356 <tr valign="top">
357 <td valign="top">xor</td>
358 <td valign="top">The part of the source that lies outside of the
359 destination is combined with the part of the destination that lies
360 outside of the source. Source or Destination, but not both. </td>
361 </tr>
362
363 </tbody>
364</table>
365
366<p>Any of the 'Src-*' methods can also be specified without the 'Src-' part.
cristyabd337d2010-08-17 01:06:59 +0000367For example the default compose method can be specified as just 'Over'.</p>
cristybc9539a2010-08-16 18:06:20 +0000368
cristyabd337d2010-08-17 01:06:59 +0000369<p>Many of these compose methods will clear the destination image which was
370not overlaid by the source image. This is to be expected as part of that
cristy075ad252010-10-30 21:56:17 +0000371specific composition methods defintion. You can disable this by setting the
372special <A HREF="../www/command-line-options.html#define"
373>-define</A> 'compose:outside-overlay' to a value of 'false' will turn off
374this behaviour. </p>
cristyabd337d2010-08-17 01:06:59 +0000375
376<p>On top of the above 12 Duff-Porter Alpha Composition methods, one special
cristybaacd172011-04-30 23:11:03 +0000377related method '<kbd>Copy</kbd>' has been provided. This is equivalent to
cristy075ad252010-10-30 21:56:17 +0000378using the '<kbd>Src</kbd>' with the special <A HREF="../www/command-line-options.html#define"
379>-define</A> option '<kbd>compose:outside-overlay</kbd>' set to
380'<kbd>false</kbd>', so as to only modify the overlaid area, without clearing
381the rest of the image outside the overlaid area. </p>
cristyabd337d2010-08-17 01:06:59 +0000382
383<br><br>
cristybc9539a2010-08-16 18:06:20 +0000384
385<p>The following mathemathical composition methods are also available. </p>
386
387<table class="doc">
388 <tbody>
389 <tr valign="top">
390 <th align="left" style="width: 8%">Method</th>
391 <th align="left">Description</th>
392 </tr>
393
394 <tr valign="top">
395 <td valign="top">multiply</td>
396 <td valign="top">The source is multiplied by the destination and replaces
397 the destination. The resultant color is always at least as dark as
398 either of the two constituent colors. Multiplying any color with black
399 produces black. Multiplying any color with white leaves the original
400 color unchanged.</td>
401 </tr>
402
403 <tr valign="top">
404 <td valign="top">screen</td>
405 <td valign="top">The source and destination are complemented and then
406 multiplied and then replace the destination. The resultant color is
407 always at least as light as either of the two constituent colors.
408 Screening any color with white produces white. Screening any color
409 with black leaves the original color unchanged.</td>
410 </tr>
411
412 <tr valign="top">
413 <td valign="top">plus</td>
414 <td valign="top">The source is added to the destination and replaces the
415 destination. This operator is useful for averaging or a controled
416 merger of two images, rather than a direct overlay.</td>
417 </tr>
418
419 <tr valign="top">
420 <td valign="top">add</td>
421 <td valign="top">As per 'plus' but transparency data is treated as matte
422 values. As such any transparent areas in either image remain
423 transparent. </td>
424 </tr>
425
426 <tr valign="top">
427 <td valign="top">minus</td>
428 <td valign="top">Subtract the colors in the source image from the
429 destination image. When transparency is involved, opaque areas is
430 subtracted from any destination opaque areas. </td>
431 </tr>
432
433 <tr valign="top">
434 <td valign="top">subtract</td>
435 <td valign="top">Subtract the colors in the source image from the
436 destination image. When transparency is involved transparent areas are
437 subtracted, so only the opaque areas in the source remain opaque in
438 the destination image. </td>
439 </tr>
440
441 <tr valign="top">
442 <td valign="top">difference</td>
443 <td valign="top">Subtracts the darker of the two constituent colors from
444 the lighter. Painting with white inverts the destination color.
445 Painting with black produces no change.</td>
446 </tr>
447
448 <tr valign="top">
449 <td valign="top">exclusion</td>
450 <td valign="top">Produces an effect similar to that of 'difference', but
451 appears as lower contrast. Painting with white inverts the
452 destination color. Painting with black produces no change.</td>
453 </tr>
454
455 <tr valign="top">
456 <td valign="top">darken</td>
457 <td valign="top">Selects the darker of the destination and source colors.
458 The destination is replaced with the source when the source is darker,
459 otherwise it is left unchanged.</td>
460 </tr>
461
462 <tr valign="top">
463 <td valign="top">lighten</td>
464 <td valign="top">Selects the lighter of the destination and source colors.
465 The destination is replaced with the source when the source is
466 lighter, otherwise it is left unchanged. </td>
467 </tr>
468
469 </tbody>
470</table>
471
472<p>Typically these use the default 'Over' alpha blending when transparencies
cristyabd337d2010-08-17 01:06:59 +0000473are also involved, except for 'Plus' which uses a 'plus' alpha blending. This
474means the alpha channel of both images will only be used to ensure that any
475visible input remains visible even in parts not overlaid. It also means that
476any values are weighted by the alpha channel of the input and output images.
477This 'Over' alpha blending is also applied to the lighting composition methods
478below. </p>
cristybc9539a2010-08-16 18:06:20 +0000479
480<p>As of IM v6.6.1-6, if the special '<kbd>Sync</kbd>' flag is not specified
cristyabd337d2010-08-17 01:06:59 +0000481(enabled by default) with the <a href="../www/command-line-options.html#channel"
482>-channel</a> setting, then the above mathematical compositions will nolonger
cristy2dcd6822011-06-13 16:21:20 +0000483synchronise its actions with the alpha channel. Instead the math composition
cristyabd337d2010-08-17 01:06:59 +0000484will be applied on an individual channel basis as defined by the <a
485href="../www/command-line-options.html#channel"
486>-channel</a>. This includes the alpha channel. This special usage
487allows you to perform true mathematics of the image channels, without alpha
488compostion effects, becomming involved. </p>
cristybc9539a2010-08-16 18:06:20 +0000489
cristyabd337d2010-08-17 01:06:59 +0000490<p>This special flag is not applied to the lighting composition methods (see
491below) even though they are closely related to mathematical composition
492methods.</p>
cristybc9539a2010-08-16 18:06:20 +0000493
cristyabd337d2010-08-17 01:06:59 +0000494<br><br>
cristybc9539a2010-08-16 18:06:20 +0000495
496<p>The following lighting composition methods are also available. </p>
497
498<table class="doc">
499 <tbody>
500 <tr valign="top">
501 <th align="left" style="width: 8%">Method</th>
502 <th align="left">Description</th>
503 </tr>
504
505 <tr valign="top">
506 <td valign="top">linear-dodge</td>
cristybaacd172011-04-30 23:11:03 +0000507 <td valign="top">This is equivalent to 'Plus' in that the color channels
cristybc9539a2010-08-16 18:06:20 +0000508 are simply added, however it does not 'Plus' the alpha channel, but
509 uses the normal 'Over' alpha blending, which transparencies are
510 involved. Produces a sort of additive multiply-like result. Added
511 ImageMagick version 6.5.4-3. </td>
512 </tr>
513
514 <tr valign="top">
515 <td valign="top">linear-burn</td>
516 <td valign="top">As 'Linear-Dodge', but also subtract one from the result.
517 Sort of a additive 'Screen' of the images. Added ImageMagick version
518 6.5.4-3. </td>
519 </tr>
520
521 <tr valign="top">
522 <td valign="top">color-dodge</td>
523 <td valign="top">Brightens the destination color to reflect the source
524 color. Painting with black produces no change.</td>
525 </tr>
526
527 <tr valign="top">
528 <td valign="top">color-burn</td>
529 <td valign="top">Darkens the destination color to reflect the source
530 color. Painting with white produces no change. Fixed in ImageMagick
531 version 6.5.4-3. </td>
532 </tr>
533
534 <tr valign="top">
535 <td valign="top">overlay</td>
536 <td valign="top">Multiplies or screens the colors, dependent on the
537 destination color. Source colors overlay the destination whilst
538 preserving its highlights and shadows. The destination color is not
539 replaced, but is mixed with the source color to reflect the lightness
540 or darkness of the destination.</td>
541 </tr>
542
543 <tr valign="top">
544 <td valign="top">hard-light</td>
545 <td valign="top">Multiplies or screens the colors, dependent on the source
546 color value. If the source color is lighter than 0.5, the destination
547 is lightened as if it were screened. If the source color is darker
548 than 0.5, the destination is darkened, as if it were multiplied. The
549 degree of lightening or darkening is proportional to the difference
550 between the source color and 0.5. If it is equal to 0.5 the
551 destination is unchanged. Painting with pure black or white produces
552 black or white.</td>
553 </tr>
554
555
556 <tr valign="top">
557 <td valign="top">linear-light</td>
558 <td valign="top">Like 'Hard-Light' but using linear-dodge and linear-burn
559 instead. Increases contrast slightly with an impact on the
560 foreground's tonal values.</td>
561 </tr>
562
563 <tr valign="top">
564 <td valign="top">soft-light</td>
565 <td valign="top">Darkens or lightens the colors, dependent on the source
566 color value. If the source color is lighter than 0.5, the destination
567 is lightened. If the source color is darker than 0.5, the destination
568 is darkened, as if it were burned in. The degree of darkening or
569 lightening is proportional to the difference between the source color
570 and 0.5. If it is equal to 0.5, the destination is unchanged. Painting
571 with pure black or white produces a distinctly darker or lighter area,
572 but does not result in pure black or white. Fixed in ImageMagick
573 version 6.5.4-3. </td>
574 </tr>
575
576 <tr valign="top">
577 <td valign="top">pegtop-light</td>
cristybaacd172011-04-30 23:11:03 +0000578 <td valign="top">Almost equivalent to 'Soft-Light', but using a
cristybc9539a2010-08-16 18:06:20 +0000579 continuious mathematical formula rather than two conditionally
580 selected formulae. Added ImageMagick version 6.5.4-3. </td>
581 </tr>
582
583 <tr valign="top">
584 <td valign="top">vivid-light</td>
585 <td valign="top">A modified 'Linear-Light' designed to preserve very stong
586 primary and secondary colors in the image. Added ImageMagick version
587 6.5.4-3. </td>
588 </tr>
589
590 <tr valign="top">
591 <td valign="top">pin-light</td>
592 <td valign="top">Similar to 'Hard-Light', but using sharp linear shadings,
593 to similate the effects of a strong 'pinhole' light source. Added
594 ImageMagick version 6.5.4-3. </td>
595 </tr>
596
597 </tbody>
598</table>
599
600
cristyabd337d2010-08-17 01:06:59 +0000601<br><br>
cristybc9539a2010-08-16 18:06:20 +0000602
603<p>Also included are these special purpose compose methods:</p>
604
605<table class="doc">
606 <tbody>
607 <tr valign="top">
608 <th align="left" style="width: 8%">Method</th>
609 <th align="left">Description</th>
610 </tr>
611
612 <tr valign="top">
cristyabd337d2010-08-17 01:06:59 +0000613 <td valign="top">copy</td>
cristybaacd172011-04-30 23:11:03 +0000614 <td valign="top">This is equivalent to the Duff-Porter composition method
cristy075ad252010-10-30 21:56:17 +0000615 '<kbd>Src,</kbd>' but without clearing the parts of the destination
cristyabd337d2010-08-17 01:06:59 +0000616 image that is not overlaid. </td>
617 </tr>
618
619 <tr valign="top">
cristybc9539a2010-08-16 18:06:20 +0000620 <td valign="top">copy-*</td>
621 <td valign="top">Copy the specified channel (Red, Green, Blue, Cyan,
622 Magenta, Yellow, Black, or Opacity) in the source image to the
623 same channel in the destination image. If the channel specified
624 does not exist in the source image, (which can only happen for methods,
625 '<kbd>copy-opacity</kbd>' or '<kbd>copy-black</kbd>') then it is
626 assumed that the source image is a special grayscale channel image
cristy075ad252010-10-30 21:56:17 +0000627 of the values that is to be copied. </td>
cristybc9539a2010-08-16 18:06:20 +0000628 </tr>
629
630 <tr valign="top">
631 <td valign="top">change-mask</td>
cristyabd337d2010-08-17 01:06:59 +0000632 <td valign="top">Replace any destination pixel that is the similar to the
633 source images pixel (as defined by the current <a
634 href="../www/command-line-options.html#fuzz">-fuzz</a> factor), with transparency.
635 </td>
cristybc9539a2010-08-16 18:06:20 +0000636 </tr>
637 </tbody>
638</table>
639
cristyabd337d2010-08-17 01:06:59 +0000640<br><br>
641
cristybc9539a2010-08-16 18:06:20 +0000642<p>On top of these composed methods are a few special ones that not only require
643the two images that are being merged or overlaid, but have some extra numerical
644arguments, which are tabled below. </p>
645
646<p>In the "<code>composite</code>" command these composition methods are
647selected using special options with the arguments needed. They are usually,
648but not always, the same name as the composte 'method' they use, and replaces
cristyabd337d2010-08-17 01:06:59 +0000649the normal use of the <a href="../www/command-line-options.html#compose" >-compose</a>
650setting in the "<code>composite</code>" command. For example... </p>
cristybc9539a2010-08-16 18:06:20 +0000651
cristyeed6cb62012-01-28 19:38:34 +0000652<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>composite ... -blend 50x50 ...</span></p>
cristybc9539a2010-08-16 18:06:20 +0000653<p>As of IM v6.5.3-4 the "<code>convert</code>" command can now also supply
cristyabd337d2010-08-17 01:06:59 +0000654these extra arguments to its <a href="../www/command-line-options.html#composite"
cristy075ad252010-10-30 21:56:17 +0000655>-composite</a> operator, using the special <a href="../www/command-line-options.html#define">-define</a>
656attribute of '<kbd class="arg">compose:args</kbd>'. This means you can now
657make use of these special argumented <a href="../www/command-line-options.html#compose"
cristyabd337d2010-08-17 01:06:59 +0000658>-compose</a> methods, those the argument and the method both need to be set
cristy29c5c992011-06-25 13:58:49 +0000659separately. For example... </p>
cristybc9539a2010-08-16 18:06:20 +0000660
cristyeed6cb62012-01-28 19:38:34 +0000661<p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert ... -compose blend -define compose:args=50,50 -composite ...</span></p>
cristybc9539a2010-08-16 18:06:20 +0000662<p>The following is a table of these special 'argumented' compose methods,
663with a brief summary of what they do. For more details see the equivalent
664"composite" command option name. </p>
665
666<table class="doc">
667 <tbody>
668 <tr valign="top">
669 <th align="left" style="width: 8%">Method</th>
670 <th align="left">Description</th>
671 </tr>
672
673 <tr valign="top">
674 <td valign="top">dissolve</td>
675 <td valign="top">Arguments:
676 <em class="arg">src_percent</em>[x<em class="arg">dst_percent</em>]
cristyabd337d2010-08-17 01:06:59 +0000677 <br>Equivalent to "<code>composite</code>" <a href="../www/command-line-options.html#dissolve">-dissolve</a>
cristybc9539a2010-08-16 18:06:20 +0000678 <br>Dissolve the 'source' image by the percentage given before overlaying
679 'over' the 'destination' image. If <em class="arg">src_percent</em> is
680 greater than 100, it starts dissolving the main image so it will
681 become transparent at a value of '<kbd class="arg">200</kbd>'. If
682 both percentages are given, each image are dissolved to the
683 percentages given.
684 </td>
685 </tr>
686
687 <tr valign="top">
688 <td valign="top">blend</td>
689 <td valign="top">Arguments:
690 <em class="arg">src_percent</em>[x<em class="arg">dst_percent</em>]
cristyabd337d2010-08-17 01:06:59 +0000691 <br>Equivalent to "<code>composite</code>" <a
692 href="../www/command-line-options.html#blend">-blend</a>
cristybc9539a2010-08-16 18:06:20 +0000693 <br>Average the images together ('plus') according to the percentages
694 given and each pixels transparency. If only a single percentage value
695 is given it sets the weight of the composite or 'source' image, while
696 the background image is weighted by the exact opposite amount. That is
697 a <kbd>-blend 30</kbd> merges 30% of the 'source' image with 70% of
698 the 'destination' image. Thus it is equivalent to <kbd>-blend
699 30x70</kbd>.
700 </td>
701 </tr>
702
703 <tr valign="top">
704 <td valign="top">mathematics</td>
705 <td valign="top">Arguments: <em class="arg">A, B, C, D</em>
706 <br>Not available in "<code>composite</code>" at this time.
707 <br>Merge the source and destination images according to the formula
708 <br>&nbsp; &nbsp; &nbsp;<code>A*Sc*Dc + B*Sc + C*Dc + D</code>
709 <br>Can be used to generate a custom composition method that would
cristyabd337d2010-08-17 01:06:59 +0000710 otherwise need to be implemented using the slow <a
711 href="../www/command-line-options.html#fx">-fx</a> DIY image operator. Added
712 to ImageMagick version 6.5.4-3.
cristybc9539a2010-08-16 18:06:20 +0000713 <br>As of IM v6.6.1-6 this method will do per-channel math compositions
cristyabd337d2010-08-17 01:06:59 +0000714 if the 'Sync' flag is removed from <a
715 href="../www/command-line-options.html#channel" >-channel</a>, just like all
716 the other mathematical compostion methods above.
cristybc9539a2010-08-16 18:06:20 +0000717 </td>
718 </tr>
719
720 <tr valign="top">
721 <td valign="top">modulate</td>
722 <td valign="top">Arguments:
723 <em class="arg">brightness</em>[x<em class="arg">saturation</em>]
cristyabd337d2010-08-17 01:06:59 +0000724 <br>Equivalent to "<code>composite</code>" <a href="../www/command-line-options.html#watermark">-watermark</a>
cristybc9539a2010-08-16 18:06:20 +0000725 <br>Take a grayscale image (with alpha mask) and modify the destination
726 image's brightness according to watermark image's grayscale value and
727 the <em class="arg">brightness</em> percentage. The destinations
728 color saturation attribute is just direct modified by the <em
729 class="arg">saturation</em> percentage, which defaults to 100 percent
730 (no color change).
731
732 </td>
733 </tr>
734
735 <tr valign="top">
736 <td valign="top">displace</td>
737 <td valign="top">Arguments:
738 <em class="arg">X-scale</em>[x<em class="arg">Y-scale</em>][!][%]
cristyabd337d2010-08-17 01:06:59 +0000739 <br>Equivalent to "<code>composite</code>" <a href="../www/command-line-options.html#displace">-displace</a>
cristybc9539a2010-08-16 18:06:20 +0000740 <br>With this option, the 'overlay' image, and optionally the 'mask'
741 image, is used as a relative displacement map, which is used to
742 displace the lookup of what part of the destination image is seen at
743 each point of the overlaid area. Much like the displacement map is a
744 'lens' that distorts the original 'background' image behind it.
745 <br><br>
cristy29c5c992011-06-25 13:58:49 +0000746 The X-scale is modulated by the 'red' channel of the overlay image
cristybc9539a2010-08-16 18:06:20 +0000747 while the Y-scale is modulated by the green channel, (the mask image
748 if given is rolled into green channel of the overlay image. This
749 separation allows you to modulate the X and Y lookup displacement
cristy29c5c992011-06-25 13:58:49 +0000750 separately allowing you to do 2-dimensional displacements, rather
751 than 1-dimensional verctored displacements (using grayscale image).
cristybc9539a2010-08-16 18:06:20 +0000752 <br><br>
753 If the overlay image contains transparency this is used as a mask
754 of the resulting image to remove 'invalid' pixels.
755 <br><br>
756 The '%' flag makes the displacement scale relative to the size of the
757 overlay image (100% = half width/height of image). Using '!' switches
758 percentage arguments to refer to the destination image size instead.
759 <br><br>
760 Special flags were added Added to ImageMagick version 6.5.3-5.
761 </td>
762 </tr>
763
764 <tr valign="top">
765 <td valign="top">distort</td>
766 <td valign="top">Arguments:
767 <em class="arg">X-scale</em>[x<em class="arg">Y-scale</em
768 >[+<em class="arg">X-center</em>+<em class="arg">Y-center</em>]][!][%]
769 <br>Not available in "<code>composite</code>" at this time.
770 <br>Exactly as per 'Displace' (above), but using absolute coordinates,
771 relative to the center of the overlay (or that given). Basically
772 allows you to generate absolute distortion maps where 'black' will
773 look up the left/top edge, and 'white' looks up the bottom/right
774 edge of the destination image, according to the scale given.
775 <br><br>
776 The '!' flag not only switches percentage scaling, to use the
777 destination image, but also the image the center offset of the lookup.
778 This means the overlay can lookup a completely different region of the
779 destination image.
780 <br><br>
781 Added to ImageMagick version 6.5.3-5.
782 </td>
783 </tr>
784
785 <tr valign="top">
786 <td valign="top">blur</td>
787 <td valign="top">Arguments:
788 <em class="arg">Width</em>[x<em class="arg">Height</em
cristy075ad252010-10-30 21:56:17 +0000789 >[+<em class="arg">Angle</em>][+<em class="arg">Angle2</em>]]
cristyabd337d2010-08-17 01:06:59 +0000790 <br>Equivalent to "<code>composite</code>" <a href="../www/command-line-options.html#blur-composite">-blur</a>
cristybc9539a2010-08-16 18:06:20 +0000791 <br>A Variable Blur Mapping Composition method, where each pixel in the
792 overlaid region is replaced with an Elliptical Weighted Average (EWA),
793 with an ellipse (typically a circle) of the given sigma size, scaled
794 according to overlay (source image) grayscale mapping.
795 <br><br>
796 As per 'Displace' and 'Distort', the red channel will modulate the
797 width of the ellipse, while the green channel will modulate the height
cristy075ad252010-10-30 21:56:17 +0000798 of the ellipse. If a single Angle value is given in the arguments,
799 then the ellipse will then be rotated by the angle specifed.
800 <br><br>
801 Normally the blue channel of the mapping overlay image is ignored.
802 However if a second ellipse angle is given, then it is assumed that
803 the blue channel defines a variable angle for the ellipse ranging from
804 the first angle to the second angle given. This allows to generate
805 radial blurs, or a rough approximation for rotational blur. Or any mix
806 of the two.
cristybc9539a2010-08-16 18:06:20 +0000807 <br><br>
808 Added to ImageMagick version 6.5.4-0.
809 </td>
810 </tr>
811
812 </tbody>
813</table>
814
815<p>To print a complete list of all the available compose operators, use <a
cristyabd337d2010-08-17 01:06:59 +0000816href="../www/command-line-options.html#list">-list compose</a>.</p>
cristybc9539a2010-08-16 18:06:20 +0000817
818
819
820</div>
821
822<div id="linkbar">
823 <span id="linkbar-west">&nbsp;</span>
824 <span id="linkbar-center">
825 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
826 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
827 </span>
828 <span id="linkbar-east">&nbsp;</span>
829 </div>
830 <div class="footer">
cristyeed6cb62012-01-28 19:38:34 +0000831 <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>
cristybc9539a2010-08-16 18:06:20 +0000832 <span id="footer-east"> <a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
833 </div>
834 <div style="clear: both; margin: 0; width: 100%; "></div>
835 <script type="text/javascript">
836 var _gaq = _gaq || [];
837 _gaq.push(['_setAccount', 'UA-17690367-1']);
838 _gaq.push(['_trackPageview']);
839
840 (function() {
841 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
842 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
843 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
844 })();
845 </script>
846</body>
847</html>