Page 1 of 1

Changing a transaparent background to a fixed colour

Posted: 2009-11-30T08:06:53-07:00
by IBeaumont
Hi,
I've got a PNG with a transaparent background. I want to put the image onto a sold whitebackground. Currently I use GIMP to a white layer and then merge the layers down. I can't seem to come up with a way to do this in ImageMagick.
Something simple like:
convert -quality 75 -background #ffffff test_image.png new_image.jpg

doesn't do the job, it always ends up on a black background.

Image

TIA
Ian

Re: Changing a transaparent background to a fixed colour

Posted: 2009-11-30T10:03:03-07:00
by Bonzo
If using a 6+ version of IM read your image in first. This should do what you want:

Code: Select all

convert test_image.png -fill red -opaque transparent -quality 75 new_image.jpg

Re: Changing a transaparent background to a fixed colour

Posted: 2009-11-30T10:10:20-07:00
by IBeaumont
Thanks - that sort of works, but looks awful. I think the issue is with semi-transparent pixels.

I have however just found a solution,

Code: Select all

convert -page +0+0 test.png  -background #ffffff -layers merge output.jpg
Thanks for the reply.