6

I'm currently writing a shellscript for Bash, that will create different size thumbnails for some rather massive amounts of large images.

I was wondering if it's possible to get GM/IM to create multiple sizes of thumbs in one run, to avoid loading the same image over and over again to create different thumbnails, thus saving memory and time in executing the script ?

4

2 回答 2

2

根据这篇文章,您可以使用-write filenameGraphicsMagick 来“将当前图像写入指定的文件名,然后继续处理......以产生各种较小的尺寸,同时只读取一次原始图像”。

于 2012-12-05T00:33:55.470 回答
1

您可以使用ImageMagick Perl bindings或绑定到您选择的任何其他语言来做到这一点:

#!/usr/bin/perl
use Image::Magick;

my($image, $x);

$image = Image::Magick->new;
$x = $image->Read('sars.png');
warn "$x" if "$x";

$x = $image->Resize(geometry=>'600x600');
warn "$x" if "$x";

$x = $image->Write('x.png');
warn "$x" if "$x";

$x = $image->Resize(geometry=>'400x400');
warn "$x" if "$x";

$x = $image->Write('y.png');
warn "$x" if "$x";

$x = $image->Resize(geometry=>'100x100');
warn "$x" if "$x";

$x = $image->Write('z.png');
warn "$x" if "$x";

conjure命令支持 XML 格式的Magick 脚本语言,但在我看来它比 Perl 版本更难,而且 Perl 绑定的文档肯定更好。

于 2011-03-25T10:21:48.160 回答