Perl resize all images

This Perl-Script resize all images to the size 166×125, I used to speed up my homepage:

#!/usr/bin/perl
opendir(DIR, "./");
@files =  grep { /\.jpg$|\.gif$/io } readdir(DIR);
sleep(10);
$count=0;
for(@files){
print "".(($count*100)/$#files)."% ".$_." - ";
$cach = 'convert "./'.$_.'" -print "%wx%h" /dev/null';
$size = `$cach`;
$size =~ /^(.+)x(.+)$/o;
print " - ".$1.":".$2;
if(defined($1) && defined($2) && ($1 > 166 || $2 > 125)){
system('mogrify -resize 166x125 "./'.$_.'"');
}
++$count;
print $/;
}
closedir(DIR);

 

2 thoughts on “Perl resize all images”

  1. Good topic. I must spend some time learning much more or figuring out more.

    Thanks for great information I was searching for this
    info for my mission.

  2. Great web site you have here.. It’s difficult to find good quality writing like yours
    nowadays. I truly appreciate individuals like you! Take care!!

Leave a Reply to ReaSPointdexter Cancel reply

Your email address will not be published.

19 − 1 =