perl: deobfuscate the year of v5.8 stability end
[sheet.git] / tools / mkimgthumb
index c672d3fdb6761fadc4768e42f0e7f1f904534dfa..fae98690b44ca18b1756ab2cc6452cea27865b8b 100755 (executable)
@@ -27,19 +27,23 @@ for (keys %opt) {
        push @ffs, my $ff = [$_];
        my $r = $opt{$_};
        push @{$ff}, -quality => $1 if $r =~ s/@(\d+)//;
        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;
 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;
        }
        unless (-e $src) {
                ($src) = grep {-e} glob qq<"$name"{,:*}.$ext> or next;
        }
+       $name =~ s/\..*//;
        s/\\(.)/$1/g for @cmds;
        print ':';
 
        s/\\(.)/$1/g for @cmds;
        print ':';
 
@@ -56,7 +60,7 @@ for my $src (@ARGV) {
                for (@ffs) {
                        my ($ff, @ffcmds) = @{$_};
                        print " $ff";
                for (@ffs) {
                        my ($ff, @ffcmds) = @{$_};
                        print " $ff";
-                       $image->convert("../$name.$ff", [@cmds, @ffcmds]);
+                       $image->convert("$target/$name.$ff", [@cmds, @ffcmds]);
                }
                1;
        } or do {
                }
                1;
        } or do {