in reply to Thumbnail autoindex

You can improve the efficiency of your script, especially when alot of images are added, by making just 1 ImageMagick object and reusing it. If you undef @$image; you can clear out all the previous data from the IM object and reuse it, which is faster than repeatedly creating a new one.
#!/usr/bin/perl use warnings; use strict; use Image::Magick; my $image = Image::Magick->new; umask 0022; my @pics= <*.jpg>; #my @pics= <*.jpg *.gif *.png>; #add all your extensions here foreach my $pic (@pics){ my ($picbasename) = $pic =~ /^(.*).jpg$/; my $ok; $ok = $image->Read($pic) and warn ($ok); my $thumb = $picbasename . '-t.jpg'; $image->Scale(geometry => '100x100'); $ok = $image->Write($thumb) and warn ($ok); undef @$image; #needed if $image is created outside loop print "$pic -> $thumb\n"; }

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: Thumbnail autoindex
by ScOut3R (Sexton) on Dec 07, 2008 at 20:09 UTC
    Thank you for the advice. I'll modify the code to use 1 ImageMagick object.