Search code examples
imagemagickimagemagick-convert

Add a transparent coloured background to png with transparency


I'm trying to do something very simple but somehow can't manage to do it.

I have an PNG with transparent areas.

How to add a background layer filled with some RGBA color such as rgba(255,0,0,128)?

I'm using imagemagick version 6 in its command line form.

This would be the PNG image for example: enter image description here


Solution

  • You can do that in ImageMagick by flattening the image against a color.

    convert sayduck.png -background "rgba(255,0,0,0.5)" -flatten result.png
    


    enter image description here