Alpha channel extraction
Posted: 2012-10-21T03:56:07-07:00
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:
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?
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");