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

Hi, Thanks for your reply. Unfortunately that didn't work. The file is .png is that going to affect anything?

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

    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?

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