perlquestion
jonnyfolk
<p>I've been messing around with this for ages now without finding a solution - I am taking a set of images from the internet and printing a thumbnail to my server. However when I run the script only a haphazard subset of the full set is written to file - I have to run the script a few times to get all the images</p>
<p>Could anyone test this to see if it an error in the code or otherwise what might be going wrong? Thanks.</p>
<code>
#!/usr/bin/perl -w
use strict;
use Image::Magick;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
print "Content-type: text/html\n\n";
my @names = qw(
http://www.coldwellbanker.com/imgs/property2002/205/14692047_1.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/78/14692047_2.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/463/14692047_3.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/336/14692047_4.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/209/14692047_5.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/82/14692047_6.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/467/14692047_7.jpg.266x200
http://www.coldwellbanker.com/imgs/property2002/340/14692047_8.jpg.266x200
);
my $count;
foreach my $item (@names) {
$count++;
my $photo = '../photo' . $count . '.jpg';
my $image = Image::Magick->new(magick=>'JPEG');
my $x = $image->Read($item);
$x = $image->Scale(width=>'50', height=> '50');
$x = $image->Write($photo);
print qq~<img src="http://www.mysite.com/$photo"><br>~;
}
exit();
</code>
<b>Additional note:</b> All of the lines are printed, 1 to 8, but some of the 'Write' are ignored, as mentioned previously, in haphazard manner.