On Oct 29, 2005, at 10:30 PM, John Horner wrote:

I installed the ImageMagick package found here:

  http://www.entropy.ch/software/macosx/welcome.html#imagemagick

and it says it installed OK, although I can't do "mogrify -args file" I have to do "/usr/local/bin/mogrify -args file"

That's your first clue - the package you installed has (correctly, IMNSHO) been configured to use the default prefix of /usr/local. That means that its command-line tools are in /usr/local/bin, libraries in /usr/local/lib, header files in /usr/local/include, etc.

That's a *good* thing, because those locations are safe from future updates to the Apple-managed directories /usr/bin, /usr/lib, and /usr/ include.

The reason you need to spell out the full path to /usr/local/bin/ mogrify is simply that /usr/local/bin is not in your $PATH. This is very basic Unix 101 - just edit ~/.bashrc and add a line like this:

    PATH=$PATH:/usr/local/bin

Then I go to install the perl Image::Magick module from CPAN, which fails with hundreds of lines of errors which look like they relate to the Magick.xs and Magick.c files:

  Magick.xs:177: warning: no semicolon at end of struct or union
  Magick.xs:181: warning: data definition has no type or storage class
  Magick.xs:182: error: parse error before '}' token

Errors can have a "cascade" effect, where an earlier error can trigger later ones. So, when troubleshooting, always look at the *first* error, not the last one. At the beginning of these hundreds of lines, you'll find the root cause, an error that looks like this:

Magick.xs:63:32: error: magick/ImageMagick.h: No such file or directory

So, why can't it find ImageMagick.h, and how do you tell it where to find that file? When all else fails, read the instructions. ;-)

In the CPAN shell, use "look Image::Magick" to download and unpack the module, and open up a subshell in the build directory. Use "less README.txt" to read the instructions. Immediately after the line that reads "cd PerlMagick", we find:

Next, edit Makefile.PL and change LIBS and INC to include the appropriate path information

and I notice that I'm installing not actually Image::Magick but something called PerlMagick, although I have installed a module called Image::Magick but it doesn't actually work when called, i.e. when I run this:

  $image->Read('pic.jpg');

it returns the error "can't open file `'".

PerlMagick is the name of the package. Image::Magick is one of several modules included in the PerlMagick package.

BTW, if you've already installed it, why are you installing it again???

One further mystery is that the Image::Magick module doesn't seem to work like a regular Perl module at all. I'm told, on this page:

  http://www.imagemagick.org/script/perl-magick.php

to use it like this:

  $x = $image->Crop(geometry=>'100x100"+100"+100');
  warn "$x" if "$x";

Looks like perfectly legal Perl to me.

rather than what I expect:

 $image->Crop(geometry=>'100x100"+100"+100') or die "$!";

I'm confused. Why would you expect a module to work in a manner that's contrary to what its documentation clearly states?

so, what's the point of a Perl module which doesn't work like Perl?

Every heard the expression "There's More Than One Way to Do It"?

A couple of possible reasons come to mind for writing the Crop() method that way. My immediate suspicion is that the Perl module simply provides a thin "wrapper" around the C functions, and the C functions were written that way. Or it may have been the module author's preference.

Whatever the reason, it's just a trivial stylistic issue - hardly something worth getting all bent out of shape over.

And what is PerlMagick? Is it a binary containing the same code as ImageMagick or just an interface to it?

ImageMagick is a library. PerlMagick provides Perl-language access to the C functions in that library.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Reply via email to