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

26 lines
546 B
Perl
Executable File

#!/usr/bin/perl
# resize to 160 on the long edge and add black border
use Image::Magick;
$source_dir = shift || ".";
my @allFiles;
opendir DIR, $source_dir;
@allFiles = grep !/^\./, readdir DIR;
closedir DIR;
foreach $file (@allFiles)
{
if ($file =~ m/^b.*?\.jpg/g)
{
print "$file\n";
$image = Image::Magick->new;
$image->Read("$source_dir/${file}");
$image->Resize(geometry=>"160x160");
$image->Border(geometry=>"2x2", fill=>"black");
$image->Write(filename=>"$source_dir/t_${file}", quality=>'75');
undef $image;
}
}