# 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.

Source: https://www.jpkc.com/db/en/cheatsheets/images-media/composite/

<!-- PROSE:intro -->
`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.
<!-- PROSE:intro:end -->

## Basic Overlay

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

```bash
composite logo.png photo.jpg result.jpg
```

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

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

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

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

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

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

## Watermarks

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

```bash
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.

```bash
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.

```bash
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.

```bash
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).

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

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

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

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

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

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

```bash
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.

```bash
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).

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

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

```bash
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).

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

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

```bash
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).

```bash
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.

```bash
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.

```bash
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.

```bash
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).

```bash
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.

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

<!-- PROSE:outro -->
## 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

- [ImageMagick: composite](https://imagemagick.org/script/composite.php) – official reference for every option of the composite command
- [ImageMagick: Compositing operators](https://imagemagick.org/Usage/compose/) – in-depth examples of `-compose` blend modes and masks
<!-- PROSE:outro:end -->

## Related Commands

- [convert](https://www.jpkc.com/db/en/cheatsheets/images-media/convert/) – the ImageMagick Swiss Army knife for converting and editing images
- [montage](https://www.jpkc.com/db/en/cheatsheets/images-media/montage/) – arrange multiple images into contact sheets and grids
- [mogrify](https://www.jpkc.com/db/en/cheatsheets/images-media/mogrify/) – batch-edit images in place

