Peamasii has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm using Image::Magick and trying to crop an image using Shave:

$image->Shave($width=>$crop_size);

I get the error:
Your vendor has not defined PerlMagick macro main::Shave

Does anyone know what this means and how I can use that method? It works fine if I pass a number instead of the variable.

Thanks!

Replies are listed 'Best First'.
(tye)Re: can't find macro in Image::Magick
by tye (Sage) on Nov 21, 2001 at 23:52 UTC

    You don't want a $ in front of "width". The call should be:     $image->Shave("width"=>$crop_size); where the quotes are optional because of how => works.

            - tye (but my friends call me "Tye")

      Thanks for pointing out a typo ;-) However the problem still occurs:

      $crop_size = int($v - $max_size);
      print "Crop size $crop_size\n";
      $x = $image->Shave(width=>$crop_size);

      Output:

      Crop size 218
      Your vendor has not defined PerlMagick macro main::Shave

      Can't figure it out, because a numeric value works, so do other methods like Crop! Can someone else try it on their systems?

        Note that this error message probably means that AUTOLOAD is being invoked. So one thought I had was that Shave() isn't available in your version of PerlMagick (but you imply that $image->Shave(width=>218) works). I don't understand why it is saying "main::Shave", though...

        After downloading PerlMagick, I see that the "main::" part is just due to some strange code in PerlMagick's AUTOLOAD which I think just needs to be removed. But that has no bearing on your problem.

        So I'm even more convinced that somehow your version of PerlMagick doesn't have a Shave() method and that $image->Shave(width=>218) will not work.

                - tye (but my friends call me "Tye")