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 ?
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".
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.
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