remove trasparency from PNG( remove alpha)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
kiranbg123@gmail.com
Posts: 5
Joined: 2018-06-28T15:02:22-07:00
Authentication code: 1152

remove trasparency from PNG( remove alpha)

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: remove trasparency from PNG( remove alpha)

Post 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
kiranbg123@gmail.com
Posts: 5
Joined: 2018-06-28T15:02:22-07:00
Authentication code: 1152

Re: remove trasparency from PNG( remove alpha)

Post by kiranbg123@gmail.com »

How do I do this in c++(magick++) flattening is working on commandline but not through c++ code
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: remove trasparency from PNG( remove alpha)

Post by fmw42 »

Sorry I do not use C++. So one of the other users or developers will need to help you.
Post Reply