How to get an alpha channel from a png

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?".

How to get an alpha channel from a png

Postby wojciech.debowski » 2007-11-16T05:52:49+00:00

Hi,

I want to create a mask image. I want to use an alpha channel as a mask but I don't know how to get an alpha channel from a png image in perl script. I am new in perl and ImageMagick, Can somebody help?
wojciech.debowski
 

Re: How to get an alpha channel from a png

Postby anthony » 2007-11-19T21:28:20+00:00

Just extract the alpha channel. look for separate in the perlmagick docs
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: How to get an alpha channel from a png

Postby wojciech.debowski » 2007-11-28T14:08:12+00:00

Separate works, thanks, but I still have a problem when converting this mask to bmp,
I have a png image and I want to have a 8bit grayscale bmp mask and 24bit bmp image, I try this to create the mask
convert image.png -channel matte -negate -separate mask.bmp
output mask.bmp has 1-bit alpha channel, later when I build from this bmp symbian mbm file I get horrible effect. How to remove this 1-bit alpha channel from output bmp image??? I tried to add -type TrueColor
convert image.png -channel matte -negate -separate -type TrueColor mask.bmp
but it didn't change anything, can someone help, it is very important for me now
wojciech.debowski
 

Re: How to get an alpha channel from a png

Postby anthony » 2007-11-28T16:00:25+00:00

To remove the alpha from the image use Evaluate to set the alpha mask to opaque. or just turn off the 'matte' channel.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: How to get an alpha channel from a png

Postby wojciech.debowski » 2007-11-29T03:38:51+00:00

I added +matte option to remove alpha channel from output image:
convert image.png -channel matte -negate -separate +matte -depth 8 mask.bmp
I still get mask.bmp with 1bit alpha channel, its type is Gra yScaleMatte, why?
I also tried to add -type Grayscale to this command but I always get GrayScaleMatte with this 1bit alpha channel.
Can You write me how to remove this alpha channel with -evaluate option?
wojciech.debowski
 

Re: How to get an alpha channel from a png

Postby anthony » 2007-11-29T19:04:30+00:00

Sounds to me like the BMP code always adds it. have you tried one of the other BMP formats.
List all formats with
Code: Select all
convert -list format

In my list I see BMP2 and BMP3 as alturnatives.
Code: Select all
convert image.png -channel matte -negate -separate +matte -depth 8 bmp3:image.bmp
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: How to get an alpha channel from a png

Postby wojciech.debowski » 2007-11-30T02:17:34+00:00

This works! Hurra hurra! alpha channel has been removed from mask.bmp,
great great great thanks!
wojciech.debowski
 


Return to Users

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Yahoo [Bot] and 12 guests