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

Have you tried if it works on the command line with the regular ImageMagick convert command (as you've quoted)?  PerlMagick wouldn't be applying any other magick, essentially...

Not all operations make sense with all image types, such as "indexed" vs. "truecolor" (PNGs may be either).   Could you provide a sample image?

Replies are listed 'Best First'.
Re^4: perlmagick color change.
by Anonymous Monk on Oct 13, 2009 at 17:21 UTC
    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!!)

      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...