Composition In ImageMagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Composition In ImageMagick

Post by anthony »

The -composite operator takes two images. A 'background' or 'destination' which determines the final size, and any meta-data (comments, labels etc) the image may have. Then a 'source' or 'overlay' image which is offset by the geometry/gravity settings for placement on the destination.

The "composite" command uses the first image as the 'source' and the second as the 'destination' images. As such the second image determines the final size (and any other meta data). You can thing of it as 'first' onto 'second'

The "convert" command reverses the order as it make mutli-operation processing much simpler.
That is think of it as 'current image' then overlay the next second image.

Read Image Composition
http://www.imagemagick.org/Usage/compose/



convert also provides other composition methods for more than two images, known as layering.

-flatten will just overlay each image onto a canvas large enough to hold JUST the first image. Actually it is the first images virtual canvas size which by definition includes the origin if the first image has a virtual offset.

-mosaic expands the canvas in positive directions to hold all images, and include the 0,0 location when 'page' or virtual offsets are used. As origin is included result will not have a virtual offset.

-layers merge will create a 'vitrual canvas' (with a possible positive or negative offset) that is JUST large enough to hold all the given images.

Read about them in Layering Images
http://www.imagemagick.org/Usage/layers/

Finally there is a composition operator to merge two separate sequences of images, or overlay one image with a sequence of images, known as -layers composite
http://www.imagemagick.org/Usage/anim_mods/#composite
It is introduced for handling animations, but really it can be ANY sequence of images.



There are other operators that also use composition, but they typically only used against individual images to add/remove borders or frames (basically composition to copy an image onto a larger canvas).


Now ALL the above is in IM Examples. And I will NOT repeat the above in the forums again!!!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply