git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perl: margin between possibly multiline list items
[sheet.git]
/
Shiar_Sheet
/
ImagePrep.pm
diff --git
a/Shiar_Sheet/ImagePrep.pm
b/Shiar_Sheet/ImagePrep.pm
index 2bd4cd9e2448add5354e8ec000635350a96120c5..328cb4f361b3bd69387cf7fe80edd45ffd639eed 100644
(file)
--- a/
Shiar_Sheet/ImagePrep.pm
+++ b/
Shiar_Sheet/ImagePrep.pm
@@
-4,7
+4,7
@@
use 5.020;
use warnings;
use experimental 'signatures';
use warnings;
use experimental 'signatures';
-our $VERSION = '1.0
2
';
+our $VERSION = '1.0
3
';
sub new ($class, $target) {
bless \$target, $class;
sub new ($class, $target) {
bless \$target, $class;
@@
-31,18
+31,19
@@
sub dimensions ($imgpath) {
return split /\s/, $xy, 3;
}
return split /\s/, $xy, 3;
}
-sub generate ($imgpath, $thumbpath, $
cmds
) {
+sub generate ($imgpath, $thumbpath, $
opt
) {
if (not -e $$imgpath) {
return !-e $thumbpath || unlink $thumbpath;
}
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,
$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};
#my ($w, $h) = $imgpath->dimensions;
#my $aspect = 3/2; # $xyres
my @cmds = @{$cmds};
@@
-71,7
+72,7
@@
sub convert ($imgpath, $thumbpath, $cmds, $xyres) {
'-strip', -quality => '60%', -interlace => 'plane',
-gravity => defined $cmds ? 'northwest' : 'center',
@cmds,
'-strip', -quality => '60%', -interlace => 'plane',
-gravity => defined $cmds ? 'northwest' : 'center',
@cmds,
-
-resize => "$xyres^", -extent => $xyres
,
+
$xyres ? (-resize => "$xyres^", -extent => $xyres) : ()
,
$thumbpath
);
$thumbpath
);