word/edit: crop coordinates separate from convert parameters
[sheet.git] / Shiar_Sheet / ImagePrep.pm
index 2bd4cd9e2448add5354e8ec000635350a96120c5..04a4270f5ac20cb87ce2be362bbfdd8d81bf3473 100644 (file)
@@ -31,14 +31,15 @@ sub dimensions ($imgpath) {
        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
        );
 }