cookutils rev 1064
modules/compressor: compress (optimize) GIF images using gifsicle
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Wed Jun 06 00:00:22 2018 +0300 (2018-06-06) |
parents | 20c2e51560fe |
children | 2233dc83fc9e |
files | doc/cookopts.txt lighttpd/index.cgi modules/compressor |
line diff
1.1 --- a/doc/cookopts.txt Mon Jun 04 11:27:06 2018 +0300 1.2 +++ b/doc/cookopts.txt Wed Jun 06 00:00:22 2018 +0300 1.3 @@ -132,6 +132,11 @@ 1.4 will not be applied to paths and default numeric precision will be 6 digits 1.5 after the dot). 1.6 1.7 +!gifz 1.8 + Default action is to compress all GIF images. 1.9 + The presence of this option overrides the default action (all GIF images 1.10 + will be left "as is"). 1.11 + 1.12 !uiz 1.13 Default action is to compress Glade UI files. Compression means the removal 1.14 of insignificant spaces and comments.
2.1 --- a/lighttpd/index.cgi Mon Jun 04 11:27:06 2018 +0300 2.2 +++ b/lighttpd/index.cgi Wed Jun 06 00:00:22 2018 +0300 2.3 @@ -539,6 +539,7 @@ 2.4 -e 's#^.*No package .* found.*#<b>\0</b>#' \ 2.5 -e 's#^.*Unable to find.*#<b>\0</b>#' \ 2.6 -e 's#[^a-zA-Z-][Ii]nvalid.*#<b>\0</b>#' \ 2.7 + -e 's#Segmentation fault#<b>\1</b>#' \ 2.8 -e 's#\([Nn][Oo][Tt] found\.*\)$#<b>\1</b>#' \ 2.9 -e 's#\(found\.*\)$#<i>\1</i>#' \ 2.10 \ 2.11 @@ -548,7 +549,7 @@ 2.12 -e 's#^.*terminated.*#<b>\0</b>#' \ 2.13 -e 's#\(missing\)#<b>\1</b>#g' \ 2.14 -e 's#^.*[Cc]annot find.*#<b>\0</b>#' \ 2.15 - -e 's#^.*unrecognized options.*#<u>\0</u>#' \ 2.16 + -e 's#^.*unrecognized option.*#<u>\0</u>#' \ 2.17 -e 's#^.*does not.*#<u>\0</u>#' \ 2.18 -e 's#^.*[Ii]gnoring.*#<u>\0</u>#' \ 2.19 -e 's#^.*note:.*#<u>\0</u>#' \
3.1 --- a/modules/compressor Mon Jun 04 11:27:06 2018 +0300 3.2 +++ b/modules/compressor Wed Jun 06 00:00:22 2018 +0300 3.3 @@ -106,6 +106,7 @@ 3.4 man) find $install/usr/share/man -type f -exec ls -l \{\} \; ;; 3.5 png) find $install -type f -name '*.png' -exec ls -l \{\} \; ;; 3.6 svg) find $install -type f -name '*.svg' -exec ls -l \{\} \; ;; 3.7 + gif) find $install -type f -name '*.gif' -exec ls -l \{\} \; ;; 3.8 xml) find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; ;; 3.9 des) find $install -type f -name '*.desktop' -exec ls -l \{\} \; ;; 3.10 mo1) find $install -type f -name '*.mo' -exec ls -l \{\} \; ;; 3.11 @@ -383,6 +384,38 @@ 3.12 } 3.13 3.14 3.15 +# Function used after compile_rules() to compress all gif images 3.16 +# Compressing can be disabled with COOKOPTS="!gifz" 3.17 + 3.18 +compress_gif() { 3.19 + time0=$(get_time) 3.20 + [ "${COOKOPTS/!gifz/}" != "$COOKOPTS" ] && return 3.21 + size0=$(sizes gif); [ -z "$size0" ] && return 3.22 + 3.23 + tpi gifsicle 3.24 + 3.25 + action 'Compressing gif images...' 3.26 + 3.27 + if which gifsicle >/dev/null; then 3.28 + the_log="$(mktemp)" 3.29 + j="$(mktemp)" 3.30 + for i in $(IFS=$'\n' find $install -type f -name '*.gif'); do 3.31 + unset IFS 3.32 + # use intermediate file, if all well ($?=0), then substitute the original 3.33 + if gifsicle -O3 "$i" -o "$j" >> "$the_log" 2>&1; then 3.34 + mv "$j" "$i" 3.35 + else 3.36 + rm "$j" 3.37 + fi 3.38 + done 3.39 + else 3.40 + echo 'Warning: gifsicle not found.' > "$the_log" 3.41 + fi 3.42 + 3.43 + comp_summary "$time0" "$size0" "$(sizes gif)" "$the_log" 3.44 +} 3.45 + 3.46 + 3.47 # Function used after compile_rules() to shrink all *.ui and *.glade files: 3.48 # remove insignificant spaces and comments 3.49 # Compressing can be disabled with COOKOPTS="!uiz" 3.50 @@ -795,6 +828,7 @@ 3.51 compress_manpages 3.52 compress_png 3.53 compress_svg 3.54 + compress_gif 3.55 compress_ui 3.56 ;; 3.57 esac