Page 1 of 1

remove trasparency from PNG( remove alpha)

Posted: 2018-06-28T15:11:36-07:00
by kiranbg123@gmail.com
Hi,
When I try to convert png to non-Png(eg JPG), the image gets corrupted if its trasparent. So I need to handle this case in my magick++ c++ code.
I am basically trying to remove transparency.
The following command line works:

1.convert transparent.png -alpha remove transparent.jpg
2.convert transparent.png -border 0 -alpha off transparent.jpg.

How can achive the same thing in c++?

I tried
1. image.alpha(off) -NOT working
2. Image.matte(false) && image.border(0) - NOT working.

I am using ImageMagick 6.9.6
Help is very much appreciated.
Thanks

Re: remove trasparency from PNG( remove alpha)

Posted: 2018-06-28T15:19:34-07:00
by fmw42
You would be best flattening the image against some background color when converting a transparent PNG to JPG.

Code: Select all

convert image.png -background white -flatten image.jpg

Re: remove trasparency from PNG( remove alpha)

Posted: 2018-06-28T15:25:38-07:00
by kiranbg123@gmail.com
How do I do this in c++(magick++) flattening is working on commandline but not through c++ code

Re: remove trasparency from PNG( remove alpha)

Posted: 2018-06-28T18:16:36-07:00
by fmw42
Sorry I do not use C++. So one of the other users or developers will need to help you.