corvée: optimise les images, nettoie les miniatures, màj le script de conversion
This commit is contained in:
parent
0b0c7f3dcc
commit
e98417ab36
922 changed files with 21 additions and 3 deletions
24
web/app/uploads/script.fish
Normal file → Executable file
24
web/app/uploads/script.fish
Normal file → Executable file
|
|
@ -1,5 +1,21 @@
|
|||
#!/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
|
||||
|
||||
|
|
@ -7,7 +23,7 @@ for jpg in **/*.{jpg,jpeg}
|
|||
set -f jxl (path change-extension 'jxl' "$jpg")
|
||||
set -f png (path change-extension 'png' "$jpg")
|
||||
|
||||
set -f dimensions (magick identify -format "%w-%h" $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
|
||||
|
|
@ -21,10 +37,12 @@ for jpg in **/*.{jpg,jpeg}
|
|||
continue
|
||||
end
|
||||
|
||||
magick "$jpg" -resize 1920x1920\> "$png" >/dev/null
|
||||
gm convert "$jpg" -resize 1920x1920\> "$png" >/dev/null
|
||||
|
||||
if ! test -e $jxl
|
||||
if test $a_bonnes_dimensions = false
|
||||
# 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 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue