diff --git a/web/app/uploads/lol.fish b/web/app/uploads/lol.fish new file mode 100644 index 00000000..d78b21a0 --- /dev/null +++ b/web/app/uploads/lol.fish @@ -0,0 +1,69 @@ +#!/usr/bin/fish + +set -f jpg $argv +echo $jpg + +set -f avif (path change-extension 'avif' "$jpg") +set -f jxl (path change-extension 'jxl' "$jpg") +set -f png (path change-extension 'png' "$jpg") + +set -f dimensions (gm identify -format "%w-%h" $jpg) +set -f dimensions (string split "-" $dimensions) + +if test $dimensions[1] -eq 1920 || test $dimensions[2] -eq 1920 + set -f a_bonnes_dimensions true +else + set -f a_bonnes_dimensions false +end + +if test -e $avif && test -e $jxl + echo -e "\tAll there." + return +end + +gm convert "$jpg" -resize 1920x1920\> "$png" >/dev/null + +if ! test -e $jxl + # Si les dimensions ne sont pas bonnes, convertis l'image PNG en JPEGXL puis reconstruis une image JPEG. + # C'est une forme de redimensionnement lossless. + if test $a_bonnes_dimensions = false + cjxl \ + --allow_jpeg_reconstruction=1 \ + --brotli_effort=11 \ + --container=1 \ + --effort=9 \ + --lossless_jpeg=1 \ + --num_threads=-1 \ + --progressive \ + $png $jxl &>/dev/null + + djxl \ + --num_threads=-1 \ + $jxl $jpg &>/dev/null + end + + cjxl \ + --allow_jpeg_reconstruction=0 \ + --brotli_effort=11 \ + --container=1 \ + --effort=10 \ + --quality=70 \ + --lossless_jpeg=0 \ + --num_threads=-1 \ + --progressive \ + $png $jxl &>/dev/null + echo -e "\t$jxl" + + set -f avif (path change-extension 'avif' "$jpg") + if ! test -e $avif + avifenc \ + -q 70 \ + -s 0 \ + -c aom \ + -y 420 \ + "$png" "$avif" &>/dev/null + echo -e "\t$avif" + end + + rm $png +end diff --git a/web/app/uploads/script.fish b/web/app/uploads/script.fish index 9a064701..76bfcf3e 100644 Binary files a/web/app/uploads/script.fish and b/web/app/uploads/script.fish differ