diff options
Diffstat (limited to 'svgo.sh.in')
-rw-r--r-- | svgo.sh.in | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/svgo.sh.in b/svgo.sh.in new file mode 100644 index 000000000000..5faf42e424e7 --- /dev/null +++ b/svgo.sh.in @@ -0,0 +1,30 @@ +#!/usr/bin/bash +# +# svgo.sh - Compress SVG files using optsvg +# + +[[ -n "$LIBMAKEPKG_TIDY_SVGO_SH" ]] && return +LIBMAKEPKG_TIDY_SVGO_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + +packaging_options+=('svgo') +tidy_modify+=('tidy_svgo') + +tidy_svgo() { + if check_option "svgo" "y"; then + msg2 "$(gettext "Optimizing SVG images...")" + local svg + find . -type f -iname "*.svg" 2>/dev/null | while read -r svg ; do + [ $(jobs -p|wc -l) -gt $(getconf _NPROCESSORS_ONLN) ] && wait -n + if [[ $(file --brief --mime-type "$svg") = 'image/svg' ]]; then + { svgo "${SVGOFLAGS[@]}" "$svg" &>/dev/null || + warning "$(gettext "Could not optimize SVG image : %s")" "${svg/$pkgdir\//}"; } & + fi + done + wait + fi +} |