Page 1 of 1
How to get an alpha channel from a png
Posted: 2007-11-16T05:52:49-07:00
by wojciech.debowski
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?
Re: How to get an alpha channel from a png
Posted: 2007-11-19T21:28:20-07:00
by anthony
Just extract the alpha channel. look for separate in the perlmagick docs
Re: How to get an alpha channel from a png
Posted: 2007-11-28T14:08:12-07:00
by wojciech.debowski
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
Re: How to get an alpha channel from a png
Posted: 2007-11-28T16:00:25-07:00
by anthony
To remove the alpha from the image use Evaluate to set the alpha mask to opaque. or just turn off the 'matte' channel.
Re: How to get an alpha channel from a png
Posted: 2007-11-29T03:38:51-07:00
by wojciech.debowski
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?
Re: How to get an alpha channel from a png
Posted: 2007-11-29T19:04:30-07:00
by anthony
Sounds to me like the BMP code always adds it. have you tried one of the other BMP formats.
List all formats with
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
Re: How to get an alpha channel from a png
Posted: 2007-11-30T02:17:34-07:00
by wojciech.debowski
This works! Hurra hurra! alpha channel has been removed from mask.bmp,
great great great thanks!