discourse-legacysite-perl/site/slowtwitch.com/www/tick/scripts/resizer.pl
2024-06-17 22:30:36 +10:00

36 lines
730 B
Perl
Executable File

#!/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();