cookutils rev 959

modules/compressor: more svg cleaning with extra options.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Aug 17 16:46:43 2017 +0300 (2017-08-17)
parents 1c2beca44d34
children 63fb59f6fd67
files doc/cookopts.txt modules/compressor
line diff
     1.1 --- a/doc/cookopts.txt	Sat Aug 12 05:00:42 2017 +0300
     1.2 +++ b/doc/cookopts.txt	Thu Aug 17 16:46:43 2017 +0300
     1.3 @@ -125,6 +125,13 @@
     1.4      The presence of this option overrides the default action (all SVG images
     1.5      will be left "as is").
     1.6  
     1.7 +!svgextra
     1.8 +    Default options assumed applying transformation to paths and reducing the
     1.9 +    accuracy of the coordinates to the tenth.
    1.10 +    The presence of this option overrides the default behaviour (transformations
    1.11 +    will not be applied to paths and default numeric precision will be 6 digits
    1.12 +    after the dot).
    1.13 +
    1.14  !uiz
    1.15      Default action is to compress Glade UI files. Compression means the removal
    1.16      of insignificant spaces and comments.
     2.1 --- a/modules/compressor	Sat Aug 12 05:00:42 2017 +0300
     2.2 +++ b/modules/compressor	Thu Aug 17 16:46:43 2017 +0300
     2.3 @@ -259,16 +259,18 @@
     2.4  
     2.5  	action 'Compressing svg images...'
     2.6  
     2.7 +	[ "${COOKOPTS/!svgextra/}" == "$COOKOPTS" ] &&
     2.8 +	opts="--apply-transform-to-paths yes --coordinates-precision 1 --paths-coordinates-precision 1"
     2.9 +
    2.10  	cleaner_log="$(mktemp)"
    2.11 -	IFS=$'\n'
    2.12 -	for i in $(find $install -type f -name '*.svg'); do
    2.13 -		echo -n "$i: " >> "$cleaner_log"
    2.14 -		svgcleaner "$i" "$i" --remove-unresolved-classes false --quiet >> "$cleaner_log"
    2.15 +	for i in $(IFS=$'\n' find $install -type f -name '*.svg'); do
    2.16 +		out="$(unset IFS; svgcleaner "$i" "$i" --copy-on-error --quiet \
    2.17 +			--multipass --remove-unresolved-classes no $opts 2>&1)"
    2.18 +		[ -z "$out" ] || echo -e "$i:\n$out\n" >> "$cleaner_log"
    2.19  	done
    2.20  
    2.21  	comp_summary "$time0" "$size0" "$(sizes svg)"
    2.22  
    2.23 -	sed -i '/: $/d' "$cleaner_log"
    2.24  	if [ -s "$cleaner_log" ]; then
    2.25  		_ 'Cleaner warnings and errors:'
    2.26  		awk '{printf "  %s\n", $0;}' "$cleaner_log"