ImageMagick: How to change transparent background to color?

Given the input image sample.i.png

with a transparent background:

enter image description here

How to convert your background to a sample.o.png

background file rgb(160,160,255)

, opacity 100% (or 1).


Used answer:

convert source.png -background "rgb(160,160,255)" -flatten out.png 

      

Please answer +1 emcconville!

+3


source to share


1 answer


From Mark an arbitrary offer . Create a background image with your color and smooth the original image over it.

 convert -size 150x150 xc:"rgb(160,160,255)" source.png -layers flatten out.png

      

example



Edit If you don't want to worry about the image size, just change the background directly.

convert source.png -background "rgb(160,160,255)" -flatten out.png 

      

Add - flatten to re-set the background color

+6


source







All Articles