After many hair-pulling frustrations I've finally got one version of the PerlMagick module working with my ActivePerl 5.10.0 build 1005. Now I'm playing with it to do some very basic color substitution.
I already can substitute one color ,say, black, with another, say, blue, using the following code:
#!perl
use strict;
use warnings;
use Image::Magick;
my $image = Image::Magick->new;
$image->Read('color-test.bmp');
$image->Opaque(fill => 'blue', color => 'black');
$image->Write('result.bmp');
But I'm wondering if I can replace any color that is not black with the color blue. I hope and think there's some idiomatic syntax to achieve this, so I'm asking for a quick help :) Any ideas?
Thanks like always for any guidance/suggestions/comments :)
UPDATE
@rjh, thank YOU for the code and the information :) I tried 'em all with a little adpations and they all work like charm!
That older version cannot be run. My PerlMagick is 6.5.4, but with a little adapation, it also works like so:
use strict;
use warnings;
use Image::Magick;
my $image = Image::Magick->new;
$image->Read('color-test.bmp');
$image->Transparent(color=>'black');
$image->Colorize(fill=>'blue');
$image->Composite(image=>$image);
$image->Write('result.bmp');
Well, of course I like your second version. It's super. It's the very syntax that I was expecting, hehe :)
And the first commandline version also works well although I was not expecting this version.
Again, thanks!