Need syntax for Recolor and level in PerlMagick

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
stully

Need syntax for Recolor and level in PerlMagick

Post by stully »

I have been trying to use these two commands like this:

Code: Select all

# 5 x 4 color matrix
$image->Recolor([1.44,0,0,0,-27.94,0,1.44,0,0,-27.94,0,0,1.44,0,-27.94,0,0,0,1,0]);

# 5 x 5 color matrix
$image->Recolor([1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);

$image->Recolor(matrix=>"1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1");

$image->Level(level=>'20%');
In each case, the Perl script finishes successfully... but the original image is unchanged.

I am using ImageMagick ver: ImageMagick 6.2.4 02/10/07 Q16
Perl is 5.something

If anyone knows the correct syntax, any help would be greatly appreciated.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Need syntax for Recolor and level in PerlMagick

Post by magick »

Recolor() requires a square matrix. In your case, 25 elements are required, you have 20.
stully

Re: Need syntax for Recolor and level in PerlMagick

Post by stully »

Thanks for looking at this. As you can see in my original post, I have tried both 4x5 and 5x5 matrices. And not only that, I guessed at a bunch of different syntaxes to specify the 5x5 matrix. I feel like I'm pretty close - and yet I might as well be miles away if I don't know the right syntax. Thanks again for any help - or pointers to an example of Recolor (or Level) in PerlMagick.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Need syntax for Recolor and level in PerlMagick

Post by magick »

We tried a matrix of the form [ ... ] with ImageMagick 6.3.6-3, the latest release and it works fine for us.
stully

Re: Need syntax for Recolor and level in PerlMagick

Post by stully »

My sysadmin just told me that the reason Recolor wasn't working was that Recolor wasn't included in the Debian package of ImageMagick.

Thanks again for your help and sorry for the confusion.
stully

Re: Need syntax for Recolor and level in PerlMagick

Post by stully »

My sysadmin can't find a copy of this file, Recolor.al in any distribution.

My Perl script is generating this error message:

Can't locate auto/Image/Magick/Recolor.al in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /usr/local/sites/matrix2.cgi line 14

Is this a bug with the version we're using? ( ImageMagick 6.2.4 02/10/07 Q16 )
Where do we find that file?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Need syntax for Recolor and level in PerlMagick

Post by magick »

Most likely the Recolor() method was not available in ImageMagick 6.2.4. To use it you need a more modern version of ImageMagick. The current release is ImageMagick 6.3.6-4.
stully

Re: Need syntax for Recolor and level in PerlMagick

Post by stully »

We just upgraded to the newest version of IM and Recolor works perfectly both at the command line and in PerlMagick.

Thanks for your help.
Post Reply