我该如何使用 Perl 脚本拉伸或调整大小任何格式的图片?
use Image::Imlib2;
# load image from file
my $image = Image::Imlib2->load("in.png");
# get some info if you want
my $width = $image->width;
my $height = $image->height;
# scale the image down to $x and $y
# you can set $x or $y to zero and it will maintain aspect ratio
my $image2 = $image->create_scaled_image($x,$y);
# save thumbnail to file
$image2->save("out.png");
如果你无法安装Imlib2,可以参考Image::Magick,此外,Image::Imlib2::Thumbnail也值得您的关注。