add --subdirs
This commit is contained in:
parent
4242dfe096
commit
36a3338ff2
1 changed files with 6 additions and 2 deletions
|
@ -22,6 +22,8 @@ unit sub MAIN(
|
||||||
Bool :v(:$verbose) = False,
|
Bool :v(:$verbose) = False,
|
||||||
#| out dir, default ./out
|
#| out dir, default ./out
|
||||||
IO(Str) :o(:$outdir) = 'out'.IO,
|
IO(Str) :o(:$outdir) = 'out'.IO,
|
||||||
|
#| use a subdirectory for each site
|
||||||
|
Bool :d(:$subdirs) = False,
|
||||||
#| defaults to all *.png & *.jpg files in the current dir
|
#| defaults to all *.png & *.jpg files in the current dir
|
||||||
*@files,
|
*@files,
|
||||||
);
|
);
|
||||||
|
@ -49,7 +51,10 @@ for @files { die "$_ is not a regular file" unless .f; }
|
||||||
# running imagemagick (and oxipng sometimes) 🪄
|
# running imagemagick (and oxipng sometimes) 🪄
|
||||||
|
|
||||||
sub convert($in, $name, $size, $format) {
|
sub convert($in, $name, $size, $format) {
|
||||||
my $out = $outdir.child($in.basename).extension("$name.$format");
|
my $out = $subdirs
|
||||||
|
?? $outdir.child($name).child($in.basename).extension("$format")
|
||||||
|
!! $outdir.child($in.basename).extension("$name.$format");
|
||||||
|
cmd <mkdir -p>, $out.dirname;
|
||||||
cmd <convert>, $in, '-resize', $size, '-quality', $quality, $out;
|
cmd <convert>, $in, '-resize', $size, '-quality', $quality, $out;
|
||||||
cmd <oxipng -q>, $out if $format == png;
|
cmd <oxipng -q>, $out if $format == png;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +81,6 @@ sub parallel(@vals, &f) {
|
||||||
@tasks».result;
|
@tasks».result;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd <mkdir -p>, $outdir;
|
|
||||||
|
|
||||||
my @todo = @files X @sites;
|
my @todo = @files X @sites;
|
||||||
parallel @todo, -> ($file, % (:$name, :$format, :$size)) {
|
parallel @todo, -> ($file, % (:$name, :$format, :$size)) {
|
||||||
|
|
Loading…
Reference in a new issue