tags:

views:

334

answers:

2

Hi,

How to stretch or resize an image (Of any Format) using a Perl script?

Could any one suggest please.

Tnx in advance.

+3  A: 

You could use Image::Resize.

mac
yeah .. cool and simple. :) I didn't want to give that one because some people might not have/want to install the library hehe
Ric Tokyo
+4  A: 

I'd recommend Image::Imlib2... if you can install imlib2 on your machine

See documentation: Image::Imlib2

use Image::Imlib2;
my $image = Image::Imlib2->load("in.png");

my $width = $image->width;
my $height = $image->height;

my $image2 = $image->create_scaled_image($x,$y);  # Scale to 100x100 pixels
# you can leave out the X or Y and it will maintain aspect ratio

$image2->save("out.png");

You might also be interested in Image::Imlib2::Thumbnail, if you can not install imlib2 have a look at Image::Magick

Ranguard