Alpha channel extraction

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
edwin
Posts: 4
Joined: 2012-10-20T13:06:57-07:00
Authentication code: 67789

Alpha channel extraction

Post by edwin »

I have a script that does a lot of alpha channel modifications. This worked fine until the distro upgraded ImageMagick from a 6.6 version to 6.7.7 (PerlMagick 6.77). After that, everything was messed up.

I found that this had to do with changes in colorspace handling and managed to get some of the things (like linear gradients) back to working order. However, I can't seem to get alpha channel extraction to work right. I reduced the problem to the following:

Code: Select all

my $img = Image::Magick->new;
$img->Read("File_With_Alpha_Channel.png");
my $alpha = $img->Clone();
$alpha->Set(alpha=>'extract');
$img->Composite(image=>$alpha, compose=>'CopyOpacity');
$img->Write("new_file.png");
Since I don't really change anything, I should end up with the same image. But no matter what I do, the alpha channel keeps changing with what looks like sRGB/RGB conversion. Is there actually something that can make this work or is there some fatal flaw at work here?
edwin
Posts: 4
Joined: 2012-10-20T13:06:57-07:00
Authentication code: 67789

Re: Alpha channel extraction

Post by edwin »

I did some digging in the code. If I read it correctly, Set(colorspace=>'RGB') is actually tied to the "-colorspace RGB" command. If this is correct, then I have been unable to find something equivalent to "-set colorspace RGB", which would be a big problem now.

I also found a workaround. I dug up a file "Adobe98.icc" under creative commons. Now I can get normal alpha scales back with
$img->Profile(name=>'Adobe98.icc');
Post Reply