# HG changeset patch # User Aleksej Bobylev # Date 1528232422 -10800 # Node ID 0af059297232b409b347d644a6ea28edc91854ed # Parent 20c2e51560fe7c95d6b986e26ab52750b7e6a335 modules/compressor: compress (optimize) GIF images using gifsicle diff -r 20c2e51560fe -r 0af059297232 doc/cookopts.txt --- a/doc/cookopts.txt Mon Jun 04 11:27:06 2018 +0300 +++ b/doc/cookopts.txt Wed Jun 06 00:00:22 2018 +0300 @@ -132,6 +132,11 @@ will not be applied to paths and default numeric precision will be 6 digits after the dot). +!gifz + Default action is to compress all GIF images. + The presence of this option overrides the default action (all GIF images + will be left "as is"). + !uiz Default action is to compress Glade UI files. Compression means the removal of insignificant spaces and comments. diff -r 20c2e51560fe -r 0af059297232 lighttpd/index.cgi --- a/lighttpd/index.cgi Mon Jun 04 11:27:06 2018 +0300 +++ b/lighttpd/index.cgi Wed Jun 06 00:00:22 2018 +0300 @@ -539,6 +539,7 @@ -e 's#^.*No package .* found.*#\0#' \ -e 's#^.*Unable to find.*#\0#' \ -e 's#[^a-zA-Z-][Ii]nvalid.*#\0#' \ + -e 's#Segmentation fault#\1#' \ -e 's#\([Nn][Oo][Tt] found\.*\)$#\1#' \ -e 's#\(found\.*\)$#\1#' \ \ @@ -548,7 +549,7 @@ -e 's#^.*terminated.*#\0#' \ -e 's#\(missing\)#\1#g' \ -e 's#^.*[Cc]annot find.*#\0#' \ - -e 's#^.*unrecognized options.*#\0#' \ + -e 's#^.*unrecognized option.*#\0#' \ -e 's#^.*does not.*#\0#' \ -e 's#^.*[Ii]gnoring.*#\0#' \ -e 's#^.*note:.*#\0#' \ diff -r 20c2e51560fe -r 0af059297232 modules/compressor --- a/modules/compressor Mon Jun 04 11:27:06 2018 +0300 +++ b/modules/compressor Wed Jun 06 00:00:22 2018 +0300 @@ -106,6 +106,7 @@ man) find $install/usr/share/man -type f -exec ls -l \{\} \; ;; png) find $install -type f -name '*.png' -exec ls -l \{\} \; ;; svg) find $install -type f -name '*.svg' -exec ls -l \{\} \; ;; + gif) find $install -type f -name '*.gif' -exec ls -l \{\} \; ;; xml) find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; ;; des) find $install -type f -name '*.desktop' -exec ls -l \{\} \; ;; mo1) find $install -type f -name '*.mo' -exec ls -l \{\} \; ;; @@ -383,6 +384,38 @@ } +# Function used after compile_rules() to compress all gif images +# Compressing can be disabled with COOKOPTS="!gifz" + +compress_gif() { + time0=$(get_time) + [ "${COOKOPTS/!gifz/}" != "$COOKOPTS" ] && return + size0=$(sizes gif); [ -z "$size0" ] && return + + tpi gifsicle + + action 'Compressing gif images...' + + if which gifsicle >/dev/null; then + the_log="$(mktemp)" + j="$(mktemp)" + for i in $(IFS=$'\n' find $install -type f -name '*.gif'); do + unset IFS + # use intermediate file, if all well ($?=0), then substitute the original + if gifsicle -O3 "$i" -o "$j" >> "$the_log" 2>&1; then + mv "$j" "$i" + else + rm "$j" + fi + done + else + echo 'Warning: gifsicle not found.' > "$the_log" + fi + + comp_summary "$time0" "$size0" "$(sizes gif)" "$the_log" +} + + # Function used after compile_rules() to shrink all *.ui and *.glade files: # remove insignificant spaces and comments # Compressing can be disabled with COOKOPTS="!uiz" @@ -795,6 +828,7 @@ compress_manpages compress_png compress_svg + compress_gif compress_ui ;; esac