Add WebP generation script
This commit is contained in:
parent
5d304908a0
commit
fba286cfc7
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/webp/
|
21
generate_webp.zsh
Executable file
21
generate_webp.zsh
Executable 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
|
Loading…
Reference in New Issue
Block a user