summarylogtreecommitdiffstats
path: root/svgo.sh.in
blob: bdef48fbca8ee46eae4387fecc5af276df7e1e4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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
			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
	fi
}