#!/usr/bin/perl use Image::Magick; sub get_files { my @allFiles; opendir DIR, "/var/www/html/one/tick/images/gallery"; @allFiles = grep !/^\./, readdir DIR; closedir DIR; foreach $file (@allFiles) { if ($file =~ m/^f\_.*?/) { print "$file\n"; $image = Image::Magick->new; $image->Read("/var/www/html/one/tick/images/gallery/${file}"); $width = $image->Get('columns'); $height = $image->Get('rows'); if (($width > 700) || ($height > 170)) { $image->Resize(geometry=>"1500x170"); $image->Write(filename=>"/var/www/html/one/tick/images/gallery/t_${file}", quality=>'80'); } undef $image; } } } &get_files();