make script generic and rename it
This commit is contained in:
parent
fba286cfc7
commit
61604461a1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/webp/
|
||||
/png/
|
||||
|
|
24
generate_raster_images.zsh
Executable file
24
generate_raster_images.zsh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Generates trimmed raster images images from SVGs in svg/.
|
||||
# Argument 1 is the file extension, default is webp.
|
||||
# Argument 2 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 ext=webp
|
||||
[[ ${ARGC} > 0 ]] && ext=${1}
|
||||
local size=-1
|
||||
[[ ${ARGC} > 1 ]] && size=${2}
|
||||
|
||||
print "generating ${ext} images in ${PWD}/${ext} …"
|
||||
mkdir -p ${ext}
|
||||
for svg in svg/*.svg; do
|
||||
local target=${svg##*/}
|
||||
target=${ext}/${target%.*}.${ext}
|
||||
convert ${svg} -trim -resize ${size} -quality 100 -verbose ${target}
|
||||
done
|
|
@ -1,21 +0,0 @@
|
|||
#!/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