使用Image:来自cpan的Magick我正在使用foreach调整一组图像:
use Image::Magick;
my @files = split(',', $cgi->param("img"));
foreach my $file (@files) {
# do something
my $image = Image::Magick->new;
my $x = $image->Read($file );
my ($width, $height, $size, $format) = $image->Ping($file);
my $dimension;
if ($width > $height) {
$dimension = 'x1500';
} else {
$dimension = '1500x';
}
$x = $image->Resize(geometry=>$dimension);
warn "$x" if "$x";
$x = $image->Write($destination);
warn "$x" if "$x";
undef $image;
}
这将正确调整图像大小。但这需要很长时间。有没有办法加快这个过程?