ImageMagick

How to layer/composite multiple images using imagemagick (convert)

In order to layer two images a.png and b.png using convert, use this syntax:

convert a.png b.png -composite out.png

In order to layer three images a.png, b.png and c.png using convert, use this syntax:

convert a.png b.png -composite c.png -composite out.png

In order to layer four images a.png up to d.png using convert, use this syntax:

convert a.png b.png -composite c.png -composite d.png -composite out.png         

In general, you need to list the first two input images without -composite, and then list every other filename including the output filename using -composite.

Posted by Uli Köhler in ImageMagick

How to convert color to transparency using ImageMagick

You can use ImageMagick to convert a given color to transparency:

convert in.png -fuzz 10% -transparent #ffffff out.png

The fuzz parameter tells ImageMagick to also convert colors within a 20% tolerance range to alpha. This is especially important for JPEG images containing compression artifacts, i.e. pixels that are not purely white. In practice, you’ll often need to play around with the fuzz parameter to select the right value.

Example:

Applied to the following image:

using

convert Transparency-example.png -fuzz 10% -transparent #ffffff out.png

you’ll generate a out.png like this:

 

Posted by Uli Köhler in ImageMagick