使用 Perl 拉伸、调整大小或缩略图 [英] Stretch, resize, or thumbnail an image using Perl

查看:54
本文介绍了使用 Perl 拉伸、调整大小或缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I stretch or resize an image (of any format) using a Perl script?

推荐答案

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

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

参见文档: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");

您可能还对 图像感兴趣::Imlib2::Thumbnail,如果你不能安装 imlib2 看看 图像::魔法

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

这篇关于使用 Perl 拉伸、调整大小或缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆