add gallery site stuff
This commit is contained in:
parent
e60a61ee76
commit
4093b1ceda
1 changed files with 13 additions and 7 deletions
|
@ -12,6 +12,8 @@ unit sub MAIN(
|
||||||
Format :i(:$itaku) is copy = DEFAULT,
|
Format :i(:$itaku) is copy = DEFAULT,
|
||||||
#| format to use for furaffinity/weasyl
|
#| format to use for furaffinity/weasyl
|
||||||
Format :f(:$furaffinity) is copy = DEFAULT,
|
Format :f(:$furaffinity) is copy = DEFAULT,
|
||||||
|
#| format to use for gallery.n.w
|
||||||
|
Format :g(:$gallery) is copy = DEFAULT,
|
||||||
#| webp/jpg quality setting (default 98)
|
#| webp/jpg quality setting (default 98)
|
||||||
Int :Q(:$quality) = 98,
|
Int :Q(:$quality) = 98,
|
||||||
#| only run conversions explicitly mentioned
|
#| only run conversions explicitly mentioned
|
||||||
|
@ -38,6 +40,7 @@ die "furaffinity/weasyl don't know what webp are" if $furaffinity == webp;
|
||||||
$mastodon ||= $only ?? skip !! webp;
|
$mastodon ||= $only ?? skip !! webp;
|
||||||
$itaku ||= $only ?? skip !! webp;
|
$itaku ||= $only ?? skip !! webp;
|
||||||
$furaffinity ||= $only ?? skip !! png;
|
$furaffinity ||= $only ?? skip !! png;
|
||||||
|
$gallery ||= $only ?? skip !! webp;
|
||||||
|
|
||||||
(@files .= map: *.IO) ||= $*CWD.dir: test => /:i \.[jpe?g|png]$/;
|
(@files .= map: *.IO) ||= $*CWD.dir: test => /:i \.[jpe?g|png]$/;
|
||||||
for @files { die "$_ is not a regular file" unless .f; }
|
for @files { die "$_ is not a regular file" unless .f; }
|
||||||
|
@ -45,20 +48,23 @@ for @files { die "$_ is not a regular file" unless .f; }
|
||||||
|
|
||||||
# running imagemagick (and oxipng sometimes) 🪄
|
# running imagemagick (and oxipng sometimes) 🪄
|
||||||
|
|
||||||
sub convert($in, $site, $format, *@flags) {
|
sub convert($in, $name, $size, $format) {
|
||||||
my $out = $outdir.child($in.basename).extension("$site.$format");
|
my $out = $outdir.child($in.basename).extension("$name.$format");
|
||||||
cmd <convert>, $in, @flags, $out;
|
cmd <convert>, $in, '-resize', $size, '-quality', $quality, $out;
|
||||||
cmd <oxipng -q>, $out if $format == png;
|
cmd <oxipng -q>, $out if $format == png;
|
||||||
}
|
}
|
||||||
|
|
||||||
constant $SIZE = 2800;
|
constant $SIZE = 2800;
|
||||||
constant $SQUARE = "{$SIZE}x{$SIZE}";
|
constant $SQUARE = "{$SIZE}x{$SIZE}>";
|
||||||
constant $MASTO-SIZE = "{1280**2}@";
|
constant $MASTO-SIZE = "{1280**2}@";
|
||||||
|
constant $GALLERY-SIZE = 3000;
|
||||||
|
constant $GALLERY-SQUARE = "{$GALLERY-SIZE}x{$GALLERY-SIZE}>";
|
||||||
|
|
||||||
my @sites = [
|
my @sites = [
|
||||||
{:name<mastodon>, :format($mastodon), :size($MASTO-SIZE)},
|
{:name<mastodon>, :format($mastodon), :size($MASTO-SIZE)},
|
||||||
{:name<itaku>, :format($itaku), :size($SQUARE)},
|
{:name<itaku>, :format($itaku), :size($SQUARE)},
|
||||||
{:name<furaffinity>, :format($furaffinity), :size($SQUARE)},
|
{:name<furaffinity>, :format($furaffinity), :size($SQUARE)},
|
||||||
|
{:name<gallery>, :format($gallery), :size($GALLERY-SQUARE)},
|
||||||
].grep: *<format> != skip;
|
].grep: *<format> != skip;
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,5 +82,5 @@ my @todo = @files X @sites;
|
||||||
parallel @todo, -> ($file, % (:$name, :$format, :$size)) {
|
parallel @todo, -> ($file, % (:$name, :$format, :$size)) {
|
||||||
state $i++;
|
state $i++;
|
||||||
say "[$i/@todo.elems()] $name $file.basename()";
|
say "[$i/@todo.elems()] $name $file.basename()";
|
||||||
convert $file, $name, $format, '-resize', $size, '-quality', $quality;
|
convert $file, $name, $size, $format;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue