From: Nicolas Boisselier Date: Tue, 23 Jun 2015 09:56:00 +0000 (+0100) Subject: nb-img2jpg X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=823d534d6f9931d17ac1796ea5be06c608b58246;p=nb.git nb-img2jpg --- diff --git a/etc/bashrc.function b/etc/bashrc.function index ada84517..5d0b41e3 100644 --- a/etc/bashrc.function +++ b/etc/bashrc.function @@ -318,13 +318,15 @@ nb-ips() { ifconfig | perl -ne '/^\s*inet (?:addr:)?([\d\.]+)/ and $1 ne "127.0.0.1" and print "$1\n"' } +alias nb-img2jpg='convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85%' + nb-img-compress() { local IFS=$'\n' i='' j='' for i in $@; do [ -e "$i" ] || continue j="${i%.*}.jpg" echo "$i -> $j" - convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% $i $j || continue + nb-img2jpg $i $j || continue [ "$i" != "$j" ] && rm "$i" done } @@ -332,5 +334,12 @@ nb-img-compress() { nb-img-compress-gray() { # See: http://www.imagemagick.org/script/command-line-options.php#colorspace # See: convert -list colorspace - nb-img-compress -colorspace Gray $@ + local IFS=$'\n' i='' j='' + for i in $@; do + [ -e "$i" ] || continue + j="${i%.*}.jpg" + echo "$i -> $j" + nb-img2jpg -colorspace Gray -normalize -level 10%,90% -sharpen 0x1 $i $j || continue + [ "$i" != "$j" ] && rm "$i" + done }