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

Unfortunately I don't have access to the command as I am on shared server space. I have tried other commands like Resize so I know that the module is responding.

The image is qr code generated from google: check it out and I am experimenting with generating different colors. (unsuccessfully!!)

Replies are listed 'Best First'.
Re^5: perlmagick color change.
by almut (Canon) on Oct 13, 2009 at 17:52 UTC

    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");
      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...