zip_image.sh

This commit is contained in:
Struchkov Mark 2024-09-18 19:54:17 +03:00
parent cc9c921007
commit f2f8786dee
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C
2 changed files with 10 additions and 11 deletions

View File

@ -66,6 +66,6 @@ steps:
# drone sign --save upagge/digital-garden # drone sign --save upagge/digital-garden
--- ---
kind: signature kind: signature
hmac: 810c6ba459d462fb8a9d63720d0b95523036ecfe7e4dfe431529833b5757a41c hmac: c9ff18295f1971e3f052359dfa8edf863932dd0f64446af39644c31253c9b189
... ...

View File

@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
file=comp.flag file=comp.flag
@ -7,25 +6,25 @@ if [ -f "$file" ]; then
fi fi
find ./images/ -type f -not -path "./images/comp/*" ! -name "*-no-comp.*" $option -iname "*.png" -exec sh -c ' find ./images/ -type f -not -path "./images/comp/*" ! -name "*-no-comp.*" $option -iname "*.png" -exec sh -c '
png_file="${1/\/images\//\/images\/comp\/}" png_file="./images/comp/${1#*/images/}"
png_dir="$(dirname "$png_file")" png_dir="$(dirname "$png_file")"
mkdir -p "$png_dir" mkdir -p "$png_dir"
cp "$1" "${png_file}" cp "$1" "$png_file"
optipng -o7 "${png_file}" optipng -o7 "$png_file"
advpng -z4 "${png_file}" advpng -z4 "$png_file"
pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow "${png_file}" pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow "$png_file"
' _ {} \; ' _ {} \;
find ./images/ -type f -not -path "./images/comp/*" ! -name "*-no-comp.*" $option -iregex '.*\.\(jpg\|jpeg\)' -exec sh -c ' find ./images/ -type f -not -path "./images/comp/*" ! -name "*-no-comp.*" $option -iregex '.*\.\(jpg\|jpeg\)' -exec sh -c '
jpg_file="${1/\/images\//\/images\/comp\/}" jpg_file="./images/comp/${1#*/images/}"
jpg_dir="$(dirname "$jpg_file")" jpg_dir="$(dirname "$jpg_file")"
mkdir -p "$jpg_dir" mkdir -p "$jpg_dir"
cp "$1" "${jpg_file}" cp "$1" "$jpg_file"
jpegoptim --all-progressive "${jpg_file}" jpegoptim --all-progressive "$jpg_file"
' _ {} \; ' _ {} \;
find ./images/comp -type f -iregex '.*\.\(jpg\|jpeg\|png\)' -not -iregex '.*no-comp\.\(jpg\|jpeg\|png\)' $option -exec sh -c ' find ./images/comp -type f -iregex '.*\.\(jpg\|jpeg\|png\)' -not -iregex '.*no-comp\.\(jpg\|jpeg\|png\)' $option -exec sh -c '
webp_file="${1/\/images\/comp\//\/images\/webp\/}" webp_file="./images/webp/${1#*/images/comp/}"
webp_dir="$(dirname "$webp_file")" webp_dir="$(dirname "$webp_file")"
mkdir -p "$webp_dir" mkdir -p "$webp_dir"
cwebp -mt -af -progress -m 6 -q 75 -pass 10 "$1" -o "${webp_file%.*}.webp" cwebp -mt -af -progress -m 6 -q 75 -pass 10 "$1" -o "${webp_file%.*}.webp"