8

如何使用 Perl 脚本拉伸或调整图像(任何格式)?

4

2 回答 2

8

我推荐 Image::Imlib2... 如果你可以在你的机器上安装 imlib2

参见文档:Image::Imlib2

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");

您可能还对Image::Imlib2::Thumbnail 感兴趣,如果您无法安装 imlib2,请查看Image::Magick

于 2009-01-28T08:47:26.700 回答
3

您可以使用Image::Resize

于 2009-01-28T08:33:28.460 回答