composite — Overlay and Composite Images with ImageMagick

Overlay images with ImageMagick composite: watermarks, overlays, masks, blend modes and stacked layers straight from the command line.

composite from the ImageMagick toolkit places one image on top of another – ideal for watermarks, logo overlays, masks and creative blend modes. With -gravity and -geometry you position the overlay to the pixel, while -dissolve and -compose control transparency and how the layers mix. In ImageMagick 7 the standalone composite is largely superseded by magick composite or magick … -composite, but stays compatible. Keep in mind that every call writes an output file: choose the target path deliberately, or you may overwrite an existing image.

Basic Overlay

composite <overlay> <background> <output> — Place overlay image on top of background image.

composite logo.png photo.jpg result.jpg

composite -gravity <position> <overlay> <background> <output> — Position the overlay using gravity (center, north, southeast, etc.).

composite -gravity southeast logo.png photo.jpg watermarked.jpg

composite -geometry +<x>+<y> <overlay> <background> <output> — Place overlay at exact pixel offset.

composite -geometry +50+100 logo.png photo.jpg result.jpg

composite -gravity center -geometry +0+<y> <overlay> <background> <output> — Center horizontally with vertical offset.

composite -gravity center -geometry +0+50 banner.png photo.jpg result.jpg

Watermarks

composite -dissolve <percent> <overlay> <background> <output> — Overlay with transparency (0-100%).

composite -dissolve 30 watermark.png photo.jpg watermarked.jpg

composite -dissolve <percent> -gravity southeast -geometry +10+10 <overlay> <background> <output> — Semi-transparent watermark in the bottom-right corner.

composite -dissolve 25 -gravity southeast -geometry +10+10 logo.png photo.jpg watermarked.jpg

composite -tile <overlay> <background> <output> — Tile the overlay across the entire background.

composite -tile watermark.png photo.jpg tiled-watermark.jpg

composite -dissolve 20 -tile <overlay> <background> <output> — Tile a semi-transparent watermark across the entire image.

composite -dissolve 20 -tile watermark.png photo.jpg tiled.jpg

Blend Modes

composite -compose Multiply <overlay> <background> <output> — Multiply blend (darkens image, useful for textures).

composite -compose Multiply texture.png photo.jpg multiplied.jpg

composite -compose Screen <overlay> <background> <output> — Screen blend (lightens image).

composite -compose Screen light-leak.png photo.jpg screened.jpg

composite -compose Overlay <overlay> <background> <output> — Overlay blend (combines multiply and screen).

composite -compose Overlay texture.png photo.jpg blended.jpg

composite -compose Difference <overlay> <background> <output> — Difference blend (highlights differences between images).

composite -compose Difference image-a.jpg image-b.jpg diff.jpg

composite -compose Dissolve -define compose:args=<percent> <overlay> <background> <output> — Dissolve blend with precise control.

composite -compose Dissolve -define compose:args=50 overlay.png base.jpg result.jpg

composite -compose SoftLight <overlay> <background> <output> — Soft light blend (subtle lighting effect).

composite -compose SoftLight light.png photo.jpg softlit.jpg

composite -compose ColorBurn <overlay> <background> <output> — Color burn blend (intensifies dark areas).

composite -compose ColorBurn texture.png photo.jpg burned.jpg

Masking

composite <overlay> <background> <mask> <output> — Use a third image as a mask (white = visible, black = hidden).

composite overlay.png background.jpg mask.png result.jpg

composite -compose CopyOpacity <mask> <input> <output> — Apply a grayscale mask as alpha channel.

composite -compose CopyOpacity mask.png photo.png masked.png

composite -compose DstIn <mask> <input> <output> — Use mask shape to clip the image (destination-in compositing).

composite -compose DstIn circle-mask.png photo.png clipped.png

Resize Overlay

composite -resize <width>x<height> <overlay> <background> <output> — Resize the overlay before compositing.

composite -resize 200x200 logo.png photo.jpg result.jpg

composite -geometry <width>x<height>+<x>+<y> <overlay> <background> <output> — Resize and position the overlay in one step.

composite -geometry 100x100+20+20 icon.png photo.jpg result.jpg

Common Patterns

for f in *.jpg; do composite -dissolve 25 -gravity southeast watermark.png "$f" "watermarked-$f"; done — Batch watermark all JPEGs in a directory.

for f in *.jpg; do composite -dissolve 25 -gravity southeast watermark.png "$f" "watermarked-$f"; done

composite -gravity center \( overlay.png -resize 50% \) background.jpg result.jpg — Resize overlay to 50% and center it (using parentheses).

composite -gravity center \( logo.png -resize 50% \) photo.jpg result.jpg

convert background.jpg overlay.png -gravity center -compose Over -composite result.jpg — Alternative syntax using convert with -composite operator.

convert photo.jpg logo.png -gravity southeast -geometry +10+10 -compose Over -composite result.jpg

Conclusion

composite is the fastest way to merge two images – from a subtle corner watermark and tiled logos to masked cut-outs and blend modes like Multiply or Screen. The key controls are -gravity and -geometry for position, -dissolve for opacity and -compose for how the layers mix. Mind the argument order (overlay first, background second) and remember that the output file is always rewritten – an accidentally identical target name overwrites your original without asking. On ImageMagick 7, magick composite or magick … -composite is the recommended form; for multi-step pipelines the -composite operator of convert/magick is often the more flexible choice.

Further Reading

  • convert – the ImageMagick Swiss Army knife for converting and editing images
  • montage – arrange multiple images into contact sheets and grids
  • mogrify – batch-edit images in place