use 5.014;
use warnings;
-our $VERSION = '1.01';
+our $VERSION = '1.02';
sub new {
my ($class, $target) = @_;
return split /\s/, $xy, 3;
}
-sub convert {
- my ($imgpath, $thumbpath, $cmds, $xyres) = @_;
+sub generate {
+ my ($imgpath, $thumbpath, $cmds) = @_;
if (not -e $$imgpath) {
return !-e $thumbpath || unlink $thumbpath;
}
+ $cmds //= [];
+ $imgpath->convert($thumbpath, $cmds, '300x200') and # low-res cover
+ $imgpath->convert($thumbpath =~ s/\.jpg$/.webp/r,
+ $cmds, '600x400' # higher dpi
+ );
+}
+sub convert {
+ my ($imgpath, $thumbpath, $cmds, $xyres) = @_;
#my ($w, $h) = $imgpath->dimensions;
- $xyres //= '300x200'; # cover
- my $aspect = 3/2;
- my @cmds = @{ $cmds // [] };
+ #my $aspect = 3/2; # $xyres
+ my @cmds = @{$cmds};
if (my ($cmdarg) = grep { $cmds[$_] eq '-area' } 0 .. $#cmds) {
# replace option by permillage crop
my @dim = map { $_ / 1000 } split /\D/, $cmds[$cmdarg + 1];