How can I stretch or resize an image (of any format) using a Perl script?
I'd recommend Image::Imlib2... if you can install imlib2 on your machine
See documentation: 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");
You might also be interested in Image::Imlib2::Thumbnail, if you can not install imlib2 have a look at Image::Magick
You could use Image::Resize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With