in reply to Re^4: perlmagick color change.
in thread perlmagick color change.

It's always good to have a sample...  As the image is black and white, I suppose the idea is to replace the white with blue. For this, you'd have to swap the colors for fill and color (color is the existing color, fill the new color):

$image->Opaque(fill => 'blue', color => 'white');

Image/PerlMagick should handle upgrading from black and white (1-bit color depth) to an appropriate color image automatically.

(Works for me when I try it with ImageMagick (command line), so I suppose PerlMagick would work as well — but I don't have it installed here at work...  Update: (...now at home): it does work with PerlMagick, too, as expected. Complete snippet below — just in case.)

#!/usr/bin/perl use Image::Magick; my $filename = shift @ARGV; my $image = new Image::Magick; $image->Read($filename); $image->Opaque(fill => 'blue', color => 'white'); $image->Write("colored_$filename");

Replies are listed 'Best First'.
Re^6: perlmagick color change.
by Anonymous Monk on Oct 13, 2009 at 19:34 UTC
    HURRAH!!
    Thanks very much. I was actually trying to replace the black for blue. However the way I written it I was replacing blue (non existant) with black (already there!) Duh!
    Thanks for sticking with me on this one...