Reputation: 258
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 ?
Upvotes: 6
Views: 1938
Reputation: 6974
According to this post you can use -write filename
with GraphicsMagick to "write the current image to the specified filename and then continue processing ... to produce the various smaller sizes while reading the original image just once".
Upvotes: 2
Reputation: 104020
You can do it with the ImageMagick Perl bindings, or bindings into any other language of your choice:
#!/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";
The conjure command supports an XML-formatted Magick Scripting Language, but it's harder on my eyes than the Perl version, and the documentation on the Perl bindings is definitely better.
Upvotes: 1