From 4093b1cedae1e96a935abb137f47c8aee27c58c3 Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Mon, 20 Nov 2023 18:43:59 +0100 Subject: [PATCH] add gallery site stuff --- bin/make-sizes | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/make-sizes b/bin/make-sizes index 09b8b2d..8facb57 100755 --- a/bin/make-sizes +++ b/bin/make-sizes @@ -12,6 +12,8 @@ unit sub MAIN( Format :i(:$itaku) is copy = DEFAULT, #| format to use for furaffinity/weasyl 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) Int :Q(:$quality) = 98, #| 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; $itaku ||= $only ?? skip !! webp; $furaffinity ||= $only ?? skip !! png; +$gallery ||= $only ?? skip !! webp; (@files .= map: *.IO) ||= $*CWD.dir: test => /:i \.[jpe?g|png]$/; 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) 🪄 -sub convert($in, $site, $format, *@flags) { - my $out = $outdir.child($in.basename).extension("$site.$format"); - cmd , $in, @flags, $out; +sub convert($in, $name, $size, $format) { + my $out = $outdir.child($in.basename).extension("$name.$format"); + cmd , $in, '-resize', $size, '-quality', $quality, $out; cmd , $out if $format == png; } -constant $SIZE = 2800; -constant $SQUARE = "{$SIZE}x{$SIZE}"; -constant $MASTO-SIZE = "{1280**2}@"; +constant $SIZE = 2800; +constant $SQUARE = "{$SIZE}x{$SIZE}>"; +constant $MASTO-SIZE = "{1280**2}@"; +constant $GALLERY-SIZE = 3000; +constant $GALLERY-SQUARE = "{$GALLERY-SIZE}x{$GALLERY-SIZE}>"; my @sites = [ {:name, :format($mastodon), :size($MASTO-SIZE)}, {:name, :format($itaku), :size($SQUARE)}, {:name, :format($furaffinity), :size($SQUARE)}, + {:name, :format($gallery), :size($GALLERY-SQUARE)}, ].grep: * != skip; @@ -76,5 +82,5 @@ my @todo = @files X @sites; parallel @todo, -> ($file, % (:$name, :$format, :$size)) { state $i++; say "[$i/@todo.elems()] $name $file.basename()"; - convert $file, $name, $format, '-resize', $size, '-quality', $quality; + convert $file, $name, $size, $format; };