Solved

Image Magick, perl- Can't get working

Posted on 2006-06-22
14
294 Views
Last Modified: 2007-12-19
Hi I just tried to install Image Magick to shrik some images, but I get the following error when I try to run my perl script?
Does anyone have any suggestions?

thank you
Steve


Can't load '/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/auto/Image/Magick/Magick.so' for module Image::Magick: libMagick.so.10: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.6/i386-linux-thread-multi/DynaLoader.pm line 230.
 at ./reize.pl line 4
Compilation failed in require at ./resize.pl line 4.
BEGIN failed--compilation aborted at ./resize.pl line 4.

------------------code below-------------------------------------------------

#!/usr/bin/perl
use strict;
use warnings;
use Image::Magick;  #this is the line the error occurs at



my $path = glob("./");

my @pageName = ();
opendir(DIR,$path) or die "can't open dir $!";
my @files = grep{/\.bmp|.JPG$/} readdir(DIR);
closedir(DIR);


my $image = Image::Magick->new();  #contains an image
foreach $image_file (@files){


    $image->Read($image_file);
    $image->Resize(geometry => '120x90');
    $image->Write($image_file);
}
0
Comment
Question by:sai4
  • 3
  • 3
  • 2
  • +2
14 Comments
 
LVL 11

Expert Comment

by:kblack05
ID: 16963032
What operating system are you using? ( I know Linux but flavor)

Try this. From command line on the server type

perl -e 'use Image::Magick;'

If you run that command and it comes back with no errors, the module is working. If the module errors, then use this command to install it:

perl -MCPAN -e 'install Image::Magick'

If installing the module fails, it's likely a software package missing (which with the shared .so config error above seems likely). At this point you use the package manager for whatever distribution you have to install Image Magick. For example on a Mandriva box it would be

urpmi ImageMagick

Also, if you have installed them, and you are still getting errors from Perl, post back and I  can provide you with more information.

Regards,

~K Black
0
 

Author Comment

by:sai4
ID: 16963272
hi K Black

perl -e 'use Image::Magick;'     gave me the same error

so I did
perl -MCPAN -e 'install Image::Magick'

got

Fetching with LWP:
  ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
Going to read /home/steve/.cpan/sources/modules/03modlist.data.gz
Going to write /home/steve/.cpan/Metadata
Image::Magick is up to date.


I then tried


perl -e 'use Image::Magick;'   but it gave me  the same error


any suggestions?

Thank you
Steve

0
 
LVL 11

Expert Comment

by:kblack05
ID: 16963348
Refer to previous post. You probably need to install core  components on the Operating System for ImageMagick. Which distro of Linux are you using? Then I can give you the steps to get it done.

0
 

Author Comment

by:sai4
ID: 16963390
Fedora Redhat 4

thank you
Steve
0
 
LVL 11

Accepted Solution

by:
kblack05 earned 500 total points
ID: 16963947
Steve,

I believe this link is what you'll need...

http://www.redhat.com/archives/fedora-package-announce/2006-May/msg00124.html

This update can be installed with the 'yum' update program.  Use 'yum update
package-name' at the command line.  For more information, refer to 'Managing
Software with yum,' available at http://fedora.redhat.com/docs/yum/.

yum imagemagick

If that installs for you, then run the perl -e commands again and see if you get the same error. Also useful is to open a second virtual terminal (ALT+F3 for example) and

tail -f /var/log/messages

Or even add this to the top of your perl script for some more verbose debugging.

Add the following snippet to your script, just beneath the shebang line (the first line of the script; usually !#/usr/local/bin/perl or !#/usr/bin/perl):

BEGIN {
open (STDERR, ">/path/to/somewhere/error.txt");
}

then after you run the perl script, you should have verbose logging in
/path/to/somewhere/error.txt

Post back if you have problems...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 17

Expert Comment

by:mjcoyne
ID: 16965888
I think you have the API (application programing interface) for ImageMagick (aka PerlMagick) installed, but you don't have the application it interfaces with (ImageMagick) installed.

See http://www.imagemagick.org/script/binary-releases.php#unix.
0
 
LVL 10

Expert Comment

by:dennis_maeder
ID: 16980280
sai4,
You have installed IM as a non-root user and your perl is looking in the standard root installed location - so it is not found when you run perl.
D
0
 
LVL 10

Expert Comment

by:dennis_maeder
ID: 16980289
This link shows the way to do cpan install as non-root user.
http://sial.org/howto/perl/life-with-cpan/non-root/
D
0
 
LVL 10

Expert Comment

by:dennis_maeder
ID: 16980299
On a different note, ImageMagick is not always compatible with system libraries, and you may do better using GD.
See e.g. http://search.cpan.org/dist/GD/
D
0
 
LVL 8

Expert Comment

by:jhurst
ID: 17163859
I would shell out to ImageMagick rather than perlMagic - this way you can test that all works well at the shell yourself rather than needing to wonder
0
 
LVL 8

Expert Comment

by:jhurst
ID: 17318347
to me it seems clear with this type of thing that one of the solutions is being used and that the questioner has just forgotten to mention it.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now