CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Code is driving me insane!!!!

 



inlimbo
User

Nov 22, 2004, 1:38 AM

Post #1 of 4 (755 views)
Code is driving me insane!!!! Can't Post

Hi,

If any one could help we here it would be excellent!!!!!!!! This thing is driving me crazy!!!!!!!! Im using a flat file database that contains the filenames of various images that I want to resize using Image::Magick. The database looks like this

#number|decription|filename
1|photo of dog|dog.jpg
2|photo of guitar|guitar.jpg
3|photo of car|car.jpg

My code is below. To me (and KevinR) looks fine but it doesnt work. I cant for the life of me figure it out. But i keep getting 500 errors.Mad
If anyone could help me and would be very very very very very much appreciated. :)

The error message that my web server got when they ran the code and the code itself is below. (Below I have substituted www.mydomain.com.au for my actual website address, so thats not the error :p)

Thanking you in advance,
inlimbo

This is the error that my web server guys got when they ran the code below.

Code
<?xml version="1.0" encoding="iso-8859-1"?> 
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"><head><title>Image Magick</title>
[Mon Nov 22 17:27:48 2004] im.cgi: Exception 410: no images to mogrify
(Resize) at /webhome/www.mydomain.com.au/cgi-bin/shoppingcart/im.cgi
line 25, <INPUT> line 1.


Here is da code.

Code
#!/usr/bin/perl -wT 
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Image::Magick;

print header;
print start_html("Image Magick");

&ProcessImages("http://www.mydomain.com.au/shoppingcart/", "database.txt");

sub ProcessImages
{
my ($dir, $filename) = @_;
my @out;
open INPUT, $filename or die "Couldn't open $filename";
while (<INPUT>)
{
chomp;
my @data = split "|";
my $imgfile = $data[2];

my $img = new Image::Magick(size=>"50x50");
if ($img->Read($dir . $imgfile))
{
$img->Resize(geometry=>"50x50");
$imgfile =~ s/.jpg$/.50x50.jpg/;
$img->Write($dir . $imgfile);
push @out, $imgfile;
}
}
close INPUT;
return @out;
}



davorg
Thaumaturge / Moderator

Nov 22, 2004, 1:53 AM

Post #2 of 4 (754 views)
Re: [inlimbo] Code is driving me insane!!!! [In reply to] Can't Post

The $img->Read method needs to be given a pathname to the image file. You are passing it a URL. That's why you're getting the error "no images to mogrify".

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


inlimbo
User

Nov 22, 2004, 6:47 AM

Post #3 of 4 (751 views)
Re: [davorg] Code is driving me insane!!!! [In reply to] Can't Post

I tried
&ProcessImages("../../shoppingcart/", "database.txt");
and
&ProcessImages("/webhome/www.mydomain.com.au/shoppingcart/", "database.txt");

but still got 500 error. ?

inlimbo...


davorg
Thaumaturge / Moderator

Nov 22, 2004, 6:53 AM

Post #4 of 4 (748 views)
Re: [inlimbo] Code is driving me insane!!!! [In reply to] Can't Post

Are you still getting the same error message?

Only you or your sysadmin can know what the correct path is.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives