summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2014-11-05 14:40:07 (GMT)
committerJan Huwald <jh@sotun.de>2014-11-05 14:40:07 (GMT)
commitec7e185f679cc48fd6ded8cec1f253bc19782150 (patch)
tree7784a1eda7169d87fc5c71a4a3f3d2f4565fd2b6
parent0619f3a03762bc03e8c4da1738d1e621470ee0b6 (diff)
terminate on missing file and return non-zero status code
to adhere to UNIX style
-rwxr-xr-xanondcim7
1 files changed, 4 insertions, 3 deletions
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 \
contact: Jan Huwald // Impressum