From ec7e185f679cc48fd6ded8cec1f253bc19782150 Mon Sep 17 00:00:00 2001 From: Jan Huwald Date: Wed, 5 Nov 2014 15:40:07 +0100 Subject: terminate on missing file and return non-zero status code to adhere to UNIX style diff --git a/anondcim b/anondcim index b968ff3..d3f2483 100755 --- a/anondcim +++ b/anondcim @@ -63,7 +63,6 @@ do # always use a padded number as destination filename suffix dst="$dst$file_prefix$(echo -n "0000000000$cur" | tail -c ${#total}).jpg" echo "anonymizing \"$fn\" to \"$dst\" ($cur/$total)" - [ -f "$fn" ] || { err "source \"$fn\" does not exist and is skipped"; continue; } [ -e "$dst" ] && { err "destination \"$dst\" for source \"$fn\" already exists, anonymization is skipped"; continue; } read w h << EOF @@ -71,15 +70,17 @@ $(identify -format '%w %h' "$fn") EOF # resize and distort - if [ $w -ge 100 ] && [ $h -ge 100 ]; then + if [ $w -ge 100 -a $h -ge 100 ] 2>/dev/null; then if [ $w -ge 1000 ]; then dw=$(($w / 100)); else dw=10; fi if [ $h -ge 1000 ]; then dh=$(($h / 100)); else dh=10; fi w=$(($w - 1)) h=$(($h - 1)) distort="-distort Perspective \"$(rand $dw) $(rand $dh) 0 0, $(($w - $(rand $dw))) $(rand $dh) $w 0, $(rand $dw) $(($h - $(rand $dh))) 0 $h, $(($w - $(rand $dw))) $(($h - $(rand $dh))) $w $h\"" - else + elif [ $w -ge 0 -a $h -ge 0 ] 2>/dev/null; then err "image $fn is too small to be distorted and will just be filtered and resized" distort= + else + die "failed to identify $fn" fi eval convert "$fn" \ -colorspace RGB \ -- cgit v0.10.1