if ! gifsicle -O2 -b "$1"; then in="$1" tmp="compress.sh-tmp-"$$".png" fin="_$1" rm -f "$fin" #sizes="32 64 128 256 512 1024 2048 4096 8192 16384 32768" #sizes="2048 4096 8192 16384 32768 65536 131072" #sizes="16384 32768 65536 131072 $[256*1024] $[512*1024] $[1024*1024]" sizes="-n1 -n2 -n3 -n4 -n5 -n6 -n7 -n8 -n9 -n10 -n11 -n12 -n13" #sizes="-b-32 -b-64 -b-128 -b-256 -b-512 -b-1024 -b-2048 -b-4096 -b-8192" #sizes="-n4 -n5 -n6 -n7" filters="0 1 2 3 4 5" #filters="0" #filters="1 3 4 5" #filters="5" advpng -z -4 "$in" optipng -o7 "$in" && advpng -z -4 "$in" #wine /usr/local/bin/DeflOpt.exe "$in" advdef -z -4 "$in" && DeflOpt "$in" for filter in $filters;do for bufsize in $sizes;do rm -f "$tmp" while [ $(jobs -p|wc -l) -ge 4 ]; do sleep 0.2; done if true; then f="$tmp"."$BASHPID".png pngout -v -f$filter $bufsize "$in" "$f" advdef -z -4 "$f" && DeflOpt "$f" flock -x 333 bsize="`stat -c %s $in`" size="`stat -c %s "$f"`" if [ $bsize -gt $size ]; then #wine /usr/local/bin/DeflOpt.exe "$f" mv -f "$f" "$fin" else rm -f "$f" fi fi & done done 333< "$in" wait mv -f "$fin" "$in" fi