ImageMagick and Perl

K

kjhjhjhjadsasda

Hi,

Im trying to get ImageMagick working on my VPS. Below code used to work
on a previous VPS, but now all I get written is $file1, never $file2.
Problem is, I dont even know how to debug it... Any clues?

$url="someimage.jpg";
$file1="pathonmyserver/something1.jpg";
$file2="pathonmyserver/something2.jpg";

my $response=LWP::UserAgent->new->get($url,':content_file'=>$file1);
$img=Image::Magick->new;
$img->Read($file1);
$img->Scale(geometry=>'548x308');
$img->Resize(width => 548, height => 308);
$img->Write(filename=>$file2);
undef $img;

Thanks!
 
G

Gunnar Hjalmarsson

Im trying to get ImageMagick working on my VPS. Below code used to work
on a previous VPS, but now all I get written is $file1, never $file2.
Problem is, I dont even know how to debug it... Any clues?

First clue:

use strict;
use warnings;

$img->Write(filename=>$file2);

my $err = $img->Write($file2) and die $err;
 
Z

zentara

Hi,

Im trying to get ImageMagick working on my VPS. Below code used to work
on a previous VPS, but now all I get written is $file1, never $file2.
Problem is, I dont even know how to debug it... Any clues?

$url="someimage.jpg";
$file1="pathonmyserver/something1.jpg";
$file2="pathonmyserver/something2.jpg";

my $response=LWP::UserAgent->new->get($url,':content_file'=>$file1);
$img=Image::Magick->new;
$img->Read($file1);
$img->Scale(geometry=>'548x308');
$img->Resize(width => 548, height => 308);
$img->Write(filename=>$file2);
undef $img;

Thanks!

Here is a thumbnail script, written by Merlyn, which shows how
to use IM in a loop cleanly, and see the error messages if any.
It's a bit tricky.

#!/usr/bin/perl

# by Merlyn

use strict;
use Image::Magick;
my $im = Image::Magick->new;

umask 0022;

my @names = @ARGV ? @ARGV : grep { -f and -B } <*>;

for (@names) {
if (/ /) {
my $old = $_;
tr, ,_,s;
$_ .= ".jpg" unless /\.jpg$/;
!-e and rename $old, $_ or next;
warn "renaming $old to $_\n";
}
next if /\.thumb\.jpg$/;
my $thumb = "$_.thumb.jpg";
next if -e $thumb;
undef @$im;
my $ret;
$ret = $im->Read($_)
and warn($ret), next;
$ret = $im->Scale( geometry => '100x100' )
and warn($ret), next;
$ret = $im->Write($thumb)
and warn($ret), next;
warn "thumbnail made for $_\n";
}
__END__
 
G

Gunnar Hjalmarsson

Michele said:
Im trying to get ImageMagick working on my VPS. Below code used to work
on a previous VPS, but now all I get written is $file1, never $file2.
Problem is, I dont even know how to debug it... Any clues?
[snip]

$img->Write(filename=>$file2);

How 'bout checking the return value of Write(), which should be the
number of images (successfully) written?

Are you sure of that? Please see the examples posted by me and zentara.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top