index: release v1.18 with only altgr index linked
[sheet.git] / tools / mkimgthumb
index 32ae1a3f2b6317511547ac728f5d6fa041f87263..e9d6eb2159286003a9ccc6c28412334d2d01ee70 100755 (executable)
@@ -27,20 +27,25 @@ for (keys %opt) {
        push @ffs, my $ff = [$_];
        my $r = $opt{$_};
        push @{$ff}, -quality => $1 if $r =~ s/@(\d+)//;
-       push @{$ff}, -resize => "$r^", -extent => $r;
+       push @{$ff}, -resize => !/\dx\d+$/ ? $_ : ("$_^", -extent => $_)
+               for split / /, $r;
 }
 
+my $target = '..';
+$target = pop @ARGV if @ARGV >= 2 and -d $ARGV[-1];
+
 my $failcount = 0;
 
 for my $src (@ARGV) {
        my ($name, @cmds) = split /:(?<!\\:)/, $src =~ s/\.(\w+)\z//r;
        my $ext = $1 // '*';
+       print $name;
        next if $name =~ m/\./;
        unless (-e $src) {
                ($src) = grep {-e} glob qq<"$name"{,:*}.$ext> or next;
        }
        s/\\(.)/$1/g for @cmds;
-       say $name;
+       print ':';
 
        if (@cmds and $cmds[0] =~ /^\d/) {
                # crop shorthand from initial dimension argument
@@ -54,14 +59,18 @@ for my $src (@ARGV) {
                my $image = Shiar_Sheet::ImagePrep->new($src);
                for (@ffs) {
                        my ($ff, @ffcmds) = @{$_};
-                       $image->convert("../$name.$ff", [@cmds, @ffcmds]);
+                       print " $ff";
+                       $image->convert("$target/$name.$ff", [@cmds, @ffcmds]);
                }
                1;
        } or do {
-               warn "error creating image:\n";
+               say ' FAILED';
                warn ref $@ eq 'ARRAY' ? $@->[1] : $@ if $@;
                $failcount++;
        };
 }
+continue {
+       say '';
+}
 
 exit $failcount;