homepage Welcome to WebmasterWorld Guest from 54.166.148.189
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
need help on Image::Magick
Terrysun




msg:3890855
 7:14 am on Apr 12, 2009 (gmt 0)

Hi, guys
i am trying to write a perl script that uploading the image files to server through the web, after uploading each file, a thumbnail for that file would be generated and store into a folder. The uploading part is working good, but when i add some codes to create thumbnail, i got the message like the following:

Software error:

Can't load 'C:/perl/site/lib/auto/Image/Magick/Magick.dll' for module Image::Magick: load_file:The specified module could not be found at C:/perl/lib/DynaLoader.pm line 202.
at C:/myweb/cgi-bin/uploadmultiple.pl line 6
Compilation failed in require at C:/myweb/cgi-bin/uploadmultiple.pl line 6.
BEGIN failed--compilation aborted at C:/myweb/cgi-bin/uploadmultiple.pl line 6.

it seems that the script couldn't find the Magick package, but it is working good if i use Image::Magick package in a script which run under terminal...

the beginning of my code is like following:
#!c:/perl/bin/perl

use strict;
use CGI;
use CGI::Carp qw (fatalsToBrowser);
use Image::Magick;

...........

can anyone help me out... thx~~~

 

rocknbil




msg:3891010
 4:26 pm on Apr 12, 2009 (gmt 0)

Welcome aboard Terrysun, I've worked a lot with ImageMagick, but never on Windows servers. At first glance, it appears to be an incomplete or improper installation.

Start with baby steps, what's the rest of this story?

but it is working good if i use Image::Magick package in a script which run under terminal...

So you're able to include the use package directive, but are you putting the methods you're using in the working script inside this terminal script?

I'm guessing you are using an ImageMagick method in your working script for which the proper libraries are not installed. ImageMagick has tons of libraries and can have the "appearance" of a proper install, but will be missing some features if they are not all installed.

To debug, take each specific function and isolate it in your command line script, hard-code known variables in so you can isolate the problem. Example:

$original_image='/full/path/to/some_big_image.jpg';
$thumbnail='/full/path/to/this_is_the_thumb.jpg';
$new_width=100; #pixels

## if called from a browser, uncomment
#print "content-type: text/html\n\n";

$pic = Image::Magick->new;
$x = $pic->Read("$original_image");
$type=$pic->GetAttribute('mime');

print "original is $type <br>\n";

$height=$pic->GetAttribute('height');
$width= $pic->GetAttribute('width');

print "H: $height W: $width <br>\n";

$newheight=int(($new_width * $height) / $width);
$newwidth=$new_width; ## redundant, but when you add to a sub it will make sense

print "new width: $newwidth New height: $newheight <br>\n";

$pic->Scale(geometry=>"${newwidth}x${newheight}");
$pic->Write("$thumbnail");

print "Done, $thumbnail was created <br>\n";

As the script executes, if it dies anywhere, you are one step closer to a solution.

Terrysun




msg:3891286
 9:52 am on Apr 13, 2009 (gmt 0)

thanks, rocknail, i really appreciate your help. i've solved the problem. Just restart the system, and everything is working well. seems Apache Server need to restart to locate the ImageMagick library

rocknbil




msg:3891479
 4:25 pm on Apr 13, 2009 (gmt 0)

LOL . . . you need a <facepalm>. Here you can use mine, it's frequently hammered but still usable. :-)

krugs




msg:3891550
 6:17 pm on Apr 13, 2009 (gmt 0)

LOL... in this case rebooting really did work! If only all problems were that easy to solve!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved