http://qs1969.pair.com?node_id=681786

I've seen allot of people asking for thumbnail generators and
scripts solving some problem similar to this.
I also needed to do this recently so I spent some minutes writing a script
for it.
It's not the most interesting/efficient thing but it cuts some time and
probably it will help somebody.
I tested it using Windows.It is dependant on Image Magick.
The exact behaviour is the following:
1)get all files in directory
2)traverse each and every one of them and see if it has usual image extension
3)if 2 happens then it gets dimensions of image
4)if height>width then it uses some predefined resolutions to which it creates new
copies of the image scaled down to the predefined resolutions.
5)if width>height it reverses the predefined resolutions height with width and does the same
as described in step 4


use strict; use warnings; my @Ll=(800,600); my @Ls=(108,81); sub get_dimensions { my ($N)=@_; my $o = `identify $N`; my ($X,$Y) = $o=~ /\ (\d+)x(\d+)\ /; return ($X,$Y); } sub convert { my ($X,$Y,$N,$M)=@_; #X,Y dimensions to convert to #N-original name of file #M-name of converted/modified file my $cmd = "convert -resize %s %s %s"; $cmd=sprintf $cmd,"$X".'x'."$Y!",$N,$M; `$cmd`; #print $cmd; } sub convert_small_large { my ($N)=@_; my ($name,$ext)=split '\.',$N; my ($Xi,$Yi)=get_dimensions $N; if($Xi>$Yi) { convert @Ll,$N,"$name-l.$ext"; convert @Ls,$N,"$name-s.$ext"; } else { convert reverse @Ll,$N,"$name-l.$ext"; convert reverse @Ls,$N,"$name-s.$ext"; }; } my @files = <*>; print join "\n",@files; for (@files) { print "converting $_ ...\n"; my $namelow=lc $_; next unless $namelow =~ /(gif|bmp|jpg|wmf|jpeg|png)$/; eval { convert_small_large $_; }; }