webCOMAND

#IMAGE Composite

Combine an image with a source image using one of a number of methods.

Prototype

#IMAGE($dst, 'Composite', $src, $x = 0, $y = 0, $method = 'over', $opacity = 100, $gravity = 'northwest', $tile = FALSE)

Parameters

  • src - Source image (aka src) to combine with destination image (aka dst).
  • x - Horizontal offset in pixels from the left edge of the existing image to place new image.
  • y - Vertical offset in pixels from the top edge of the existing image to place new image.
  • method - One of the following methods.  More in-depth information can be found on the ImageMagick Compositing Image Examples page.
    • No - Do not composite the src onto the dst.
    • Add - Add all RGB values of src to dst, with overflow wrapping around (mod 256).
    • Atop - Union of the two images, with opaque areas of src obscuring dst in the region of overlap, but only opaque areas of the dst will be updated.  In other words, the transparent areas of dst will remain transparent.
    • Blend - Union of the two images, where transparent areas of dst will show through to the src, and edges of dst will be blended and anti-aliased to the src.
    • BumpMap - Dst will be shaded by the grey-scale values of the src.
    • Clear - Clear dst, regardless of src.
    • ColorBurn - The reverse of ColorDodge, equivalent to inverting all the input and output images. The result is that the dst is darkened by a dark masking src, while white produces no darkening.  However unlike either Multiply, a pure black or all white dst will remain uneffected by the src.  In other words, only areas containing grays and non-pure color is affected.
    • ColorDodge - Use the src as a mask that sort of protects dst from "light exposure" over long periods of time.  The parts exposed to a lighter mask is made lighter (dodged), while black areas produce no change.  You can think of it as placing an object on top of a photo for a very long time, causing the parts exposed to light to slowly whiten with age, while the parts that were covered remain as they were.  A pure black overlay does not change the image while a pure white overlay will make all the background colors white, except for those that were pure black.
    • Colorize - Copy the hue and saturation from src to dst, leaving the color luminance unchanged.
    • CopyBlack - Copy the "black channel" from src to dst, if it exists. The channel only exists for CMYK images.
    • CopyBlue - Copy the "blue channel" from src to dst, if it exists. As a gray-scale RGB image has the same data in all three color channels, this method can be thought of as copying a greyscale channel image to replace the blue channel in the destination image.
    • Copy - Similar to the Src method, but it does not touch the dst image where the src is transparent.
    • CopyCyan - A synonym for CopyRed when working with CYMK images.  As the "red channel" in RGB images is also used as the "cyan channel" in CYMK images.
    • CopyGreen - Copy the "green channel" from src to dst, if it exists. As a gray-scale RGB image has the same data in all three color channels, this method can be thought of as copying a greyscale channel image to replace the green channel in the destination image.
    • CopyMagenta - A synonym for CopyGreen when working with CYMK images.  As the "green channel" in RGB images is also used as the "magenta channel" in CYMK images.
    • CopyOpacity - Copy the transparency channel of src into dst.  When the src has no alpha channel, it will treat src as a grey-scale image mask, where black is fully transparent and white is fully opaque.
    • CopyRed - Copy the "red channel" from src to dst, if it exists. As a gray-scale RGB image has the same data in all three color channels, this method can be thought of as copying a greyscale channel image to replace the red channel in the destination image.
    • CopyYellow - A synonym for CopyBlue when working with CYMK images.  As the "blue channel" in RGB images is also used as the "yellow channel" in CYMK images.
    • Darken - Compare the src and dst color values and take the respective darker value.
    • DstAtop - Union of the two images, with opaque areas of dst obscuring src in the region of overlap, but only opaque areas of the src will be updated.  In other words, the transparent areas of src will remain transparent.
    • Dst - Only keep dst.  Ignore src.
    • DstIn - Keep dst pixels that overlap opaque src pixels.
    • DstOut - Make dst pixels that overlap opaque src pixels transparent.
    • DstOver - The result will be the union of the two images, with opaque areas of dst obscuring src in the region of overlap.
    • Difference - The absolute difference in the color values.  Black and white difference will produce a maximum result of white while any colors which are the same will produce black.
    • Displace -
    • Dissolve - A controlled Over method, which adjusts the transparency of the src, before it is overlaid on top of dst, according to the percentages given.
    • Exclusion - This is sort of an averaged difference. White on white will produce black (no difference), the same with black on black.  However grey on grey will produce a grey result.  White and black naturally still produce white (maximum difference).
    • HardLight -
    • Hue - Copy the hue of the src to dst, leaving dst saturation and luminance.
    • In - Keep src pixels that overlap opaque dst pixels.
    • Lighten - Compare the src and dst color values and take the respective lighter value.
    • Luminize - Copy the luminance from src to dst, leaving the hue and saturation unchanged.
    • Minus - Subtract the RGB values of dst from src.
    • Modulate - Discolor images in HSB space for copyright purposes, to apply a watermark. The src is an alpha masked black and white image, which is used to brighten/darken the dst by the brightness percentage given.  A brightness of 0 makes no change in the image brightness, though a value of 100 replaces the brightness with the intensity of the src.  That is, if the src is black the dst is made black, if white the destination image's color will be fully saturated.
    • Multiply - Multiply the RGB values of the src and dst.  This means that if one of the images is pure white, the result will be the other image.  On the other hand if one image is black the result will be black.  Between these extremes, the src will darken the dst by the amount given.  It will only darken an image, it will never brighten it.
    • Out - Make opaque dst pixels transparent in src.
    • Over - The result will be the union of the two images, with opaque areas of src obscuring dst in the region of overlap.
    • Overlay - Multiply (darken) and Screen (lighten) an image at the same time.  The method applied to each pixel is determined by the value of the dst, which can be regarded as a "lighting mask".  Because of this the dst is generally a grey-scale image, to which color is being added.  The result preserves pure white and black (highlights) that are present in the dst while tinting the mid-tone greys by the colors in the src.
    • Plus - Sum src and dst RBG values.  Values are cropped to 255 (no overflow). This operation is independent of the matte channels.
    • Replace - Replace dst pixels with src pixels, including transparency.
    • Saturate - Copy the saturation from src to dst, leaving dst hue and luminance.
    • Screen - Similar to Multiply, except both src and dst are negated before the compose, and the final result is also then negated again to return the image to normal. In technical terms the two methods are 'Duals' of each other.  That makes its formula: 1-(1-Src)*(1-Dest).  This means that if one of the images is pure black, the result will be the other image. On the other hand if one image is white the result will be white. Between these extremes one image will lighten the destination image by the amount given.  It will only make an image brighter, never darker.  This is also known 'dodge' composition.  This method is perfect for overlaying white text on a black background, then onto other images.
    • SoftLight - Add highlights and shadows to the src image to produce a softer contrast, and smoother gradient in lighting effects. The dst is typically the greyscale lighting mask.
    • SrcAtop - Union of the two images, with opaque areas of src obscuring dst in the region of overlap, but only opaque areas of the dst will be updated.  In other words, the transparent areas of dst will remain transparent.  Same as Atop.
    • Src - Only keep src.  Ignore dst.
    • SrcIn - Keep src pixels that overlap opaque dst pixels.  Same as In.
    • SrcOut - Make src pixels that overlap opaque dst pixels transparent.
    • SrcOver - The result will be the union of the two images, with opaque areas of src obscuring dst in the region of overlap.  Same as Over.
    • Subtract - Same as Minus, except that it is a modulus subtraction.  Subtracting 'white' from 'gray' will result in the original 'gray', and not black, as the values wrap back around.
    • Threshold - Dst RGB values that exceed the specified src RGB value threshold are reassigned the maximum channel value, while all other values are assigned the minimum.  The minimum value is 0 (corresponding to black when all channels are affected) and the maximum value is 255 (corresponding to white).
    • Xor - Combine the dst and srt using the XOR operation on RGB values.
  • opacity - Opacity of src image (0=transparent, 100=opaque).
  • gravity - NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast.
  • tile - If TRUE, tile src image from x, y position to the left and bottom of dst.

Example

#/ composite a new image by placing a logo over a background
#NEW($img)#IMAGE($bg,Composite,$logo,80,100)#ENDNEW

#/ composite a new image by placing a logo over a background
#NEW($img)#IMAGE($bg,Composite,$logo,80,100,Over,50,West,TRUE)#ENDNEW