use warnings;
use experimental 'signatures';
-our $VERSION = '1.02';
+our $VERSION = '1.03';
sub new ($class, $target) {
bless \$target, $class;
return split /\s/, $xy, 3;
}
-sub generate ($imgpath, $thumbpath, $cmds) {
+sub generate ($imgpath, $thumbpath, $opt) {
if (not -e $$imgpath) {
return !-e $thumbpath || unlink $thumbpath;
}
- $cmds //= [];
- $imgpath->convert($thumbpath, $cmds, '300x200') and # low-res cover
+ my @cmds = @{$opt->{convert} // []};
+ unshift @cmds, -area => $_ for $opt->{crop32} || ();
+ $imgpath->convert($thumbpath, \@cmds, '300x200') and # low-res cover
$imgpath->convert($thumbpath =~ s/\.jpg$/.webp/r,
- [@{$cmds}, -quality => 40], '600x400' # higher dpi tradeoff
+ [@cmds, -quality => 40], '600x400' # higher dpi tradeoff
);
}
-sub convert ($imgpath, $thumbpath, $cmds, $xyres) {
+sub convert ($imgpath, $thumbpath, $cmds, $xyres = 0) {
#my ($w, $h) = $imgpath->dimensions;
#my $aspect = 3/2; # $xyres
my @cmds = @{$cmds};
'-strip', -quality => '60%', -interlace => 'plane',
-gravity => defined $cmds ? 'northwest' : 'center',
@cmds,
- -resize => "$xyres^", -extent => $xyres,
+ $xyres ? (-resize => "$xyres^", -extent => $xyres) : (),
$thumbpath
);