8

Perl スクリプトを使用して (任意の形式の) 画像を拡大またはサイズ変更するにはどうすればよいですか?

4

2 に答える 2

8

マシンに imlib2 をインストールできる場合は、Image::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 に答える