I am trying to set up PerlMagick for use with Matlab and take advantage of the fact that Matlab lets you run Perl scripts. I have got PerlMagick to work just fine outside of Matlab but have hit a problem on the Matlab side of things.
Here is a summary of progress so far.
Using Windows XP Service Pack 3 ( I think it's SP3 – it might by SP2)
Using Matlab R2009b in the example below. R2010b gives exactly the same result.
Perl installed from Active Perl on November 9th 2010 into C:\Perl.
Using ImageMagick 6.6.5 installed from website into C:\Program Files\ImageMagick-6.6.5-Q16 on November 9th 2010. Perl was installed first as per installation instructions.
Tested PerlMagick from the command line and it all worked perfectly. Got all the examples to work and produce output. Fantastic.
I then tried to run PerlMagick from Matlab. Matlab allows you to run Perl scripts from the Matlab command line using the 'perl' command, e.g., >> perl('example.pl')
Matlab installs Perl into this folder C:/Program Files/MATLAB/R2009b/sys/ (if it is R2009b)
I'd like to be able to run PerlMagick in this way. I have Perl installed twice on the PC – in C:\Perl and in folder C:/Program Files/MATLAB/R2009b/sys as the Matlab default. This 2nd installation needs to be configured for use with PerlMagick.
Progress so far.
MATLAB Perl session
1. First attempt to run a PerlMagick script from Matlab to see what happens. I did not expect it to work. I wanted to see what errors I get.
>> perl('button.pl')
??? Error using ==> perl at 82
System error: Can't locate Image/Magick.pm in @INC
(@INC contains: C:/Program Files/MATLAB/R2009b/sys/perl/win32/site/lib C:/Program
Files/MATLAB/R2009b/sys/perl/win32/lib .) at button.pl
line 5.
BEGIN failed--compilation aborted at button.pl line 5.
Command executed: perl button.pl
OK. No surprise. It can't find the PerlMagick files.
2. Second attempt after copying the Image folder from C:\Perl\site\lib to C:/Program Files/MATLAB/R2009b/sys/perl/win32/site/lib.
Added file Magick.pm to C:/Program Files/MATLAB/R2009b/sys/perl/win32/site/lib/Image
>> perl('button.pl')
??? Error using ==> perl at 82
System error: Can't locate loadable object for module
Image::Magick in @INC (@INC contains: C:/Program
Files/MATLAB/R2009b/sys/perl/win32/site/lib C:/Program
Files/MATLAB/R2009b/sys/perl/win32/lib .) at button.pl
line 5
Compilation failed in require at button.pl line 5.
BEGIN failed--compilation aborted at button.pl line 5.
Command executed: perl button.pl
OK. No surprise. A different error message. It can't find the Image::Magick module.
3. Third attempt after copying the auto folder from C:\Perl\site\lib to C:/Program Files/MATLAB/R2009b/sys/perl/win32/site/lib.
>> perl('button.pl')
??? Error using ==> perl at 82
System error: Command executed: perl button.pl
Also got one of those Microsoft message boxes with the mssages "Perl Command Line Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience." and "Please tell Microsoft about this problem."
I'm not sure I expected it to work at this point but I do not know what's wrong.
It is probably something in the set-up that has been missed but I do not know what. Any suggestions?