corvée: optimise les images, nettoie les miniatures, màj le script de conversion
This commit is contained in:
parent
6aa7a257d2
commit
18c603fc6a
2364 changed files with 1679 additions and 0 deletions
86
web/app/uploads/script.fish
Normal file
86
web/app/uploads/script.fish
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
if type --query gm
|
||||
else
|
||||
echo -e "GraphicsMagick is missing."
|
||||
exit 1
|
||||
end
|
||||
if type --query cjxl
|
||||
else
|
||||
echo -e "A JPEGXL encoder (cjxl) is missing."
|
||||
exit 1
|
||||
end
|
||||
if type --query avifenc
|
||||
else
|
||||
echo -e "An AVIF encoder (avifenc) is missing."
|
||||
exit 1
|
||||
end
|
||||
|
||||
for jpg in **/*.{jpg,jpeg}
|
||||
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."
|
||||
continue
|
||||
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
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue