Given an input image sample.i.png
with a transparent background :
How to convert its background into a file sample.o.png
with background rgb(160,160,255)
, opacity 100% (or 1).
Answer used:
convert source.png -background "rgb(160,160,255)" -flatten out.png
Please +1 emcconville's answer !
The GIF and PNG formats also both support transparency. If you need any level of transparency in your image, you must use either a GIF or a PNG. GIF images (and also PNG) support 1-color transparency. This basically means that you can save your image with a transparent background.
To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).
From Mark Random's suggestion. Create a background image with your color, and flatten the source image over it.
convert -size 150x150 xc:"rgb(160,160,255)" source.png -layers flatten out.png
Edit If you don't want to worry about image size, just change the background directly.
convert source.png -background "rgb(160,160,255)" -flatten out.png
Add the -flatten to re-set the background color
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With