Add WebP generation script

This commit is contained in:
tastytea 2022-06-12 03:12:45 +02:00
parent 5d304908a0
commit fba286cfc7
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 22 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/webp/

21
generate_webp.zsh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env zsh
# Generates trimmed WebP images from SVGs in svg/.
# First argument is the size, default is to use the SVG size.
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
if ! type convert &> /dev/null; then
print -u2 "'convert' from imagemagick not found"
return 1
fi
local size=-1
[[ ${ARGC} > 0 ]] && size=${1}
print "generating WebP images in ${PWD}/webp …"
mkdir -p webp
for svg in svg/*.svg; do
local webp=${svg##*/}
webp=webp/${webp%.*}.webp
convert ${svg} -trim -resize ${size} -quality 100 -verbose ${webp}
done