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
);
}
convert => {-label => 'Convert options', -json => 'image', -multiple => 1, -src => sub {
return "data/word/32/$_[0]->{id}.jpg";
}},
+ crop32 => {-label => 'Crop 3:2', -json => 'image'},
story => {-label => 'Story', type => 'textarea', hidden => 'hidden'},
);
$reimage++ if $fields{rethumb}; # force refresh
if ($reimage) {
eval {
- $image->generate($wordcol{convert}->{-src}->($row), $imagecol->{convert});
+ $image->generate($wordcol{convert}->{-src}->($row), $imagecol);
} or do {
my ($warn, @details) = ref $@ ? @{$@} : $@;
Alert([ "Thumbnail image not generated", $warn ], @details);