summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2014-11-05 14:33:47 (GMT)
committerJan Huwald <jh@sotun.de>2014-11-05 14:33:47 (GMT)
commitc62a4c9913a7d5fb498283c80fa6948368cae25c (patch)
treee643367ce4b2528eb3a327cb6a13ccae57efff26
parentad0081e62008b38a7e35cb88434cd87f105975f4 (diff)
DRY
-rwxr-xr-xanondcim32
1 files changed, 12 insertions, 20 deletions
diff --git a/anondcim b/anondcim
index 3ccf772..6c2dc42 100755
--- a/anondcim
+++ b/anondcim
@@ -71,32 +71,24 @@ $(identify -format '%w %h' "$fn")
EOF
# resize and distort
- if [ $w -ge 100 ] && [ $h -ge 100 ]
- then
+ if [ $w -ge 100 ] && [ $h -ge 100 ]; 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))
-
- convert "$fn" \
- -colorspace RGB \
- -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" \
- -filter gaussian -define filter:support=5 -define filter:sigma=0.5 \
- -attenuate 2 +noise Uniform \
- -resize "$dst_size" \
- -colorspace sRGB \
- "$dst"
+ 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
- err "image is too small to be distorted and will just be filtered and resized"
- convert "$fn" \
- -colorspace RGB \
- -filter gaussian -define filter:support=5 -define filter:sigma=0.5 \
- -attenuate 2 +noise Uniform \
- -resize "$dst_size" \
- -colorspace sRGB \
- "$dst"
+ err "image $fn is too small to be distorted and will just be filtered and resized"
+ distort=
fi
+ eval convert "$fn" \
+ -colorspace RGB \
+ $distort \
+ -filter gaussian -define filter:support=5 -define filter:sigma=0.5 \
+ -attenuate 2 +noise Uniform \
+ -resize "$dst_size" \
+ -colorspace sRGB \
+ "$dst"
# remove metadata
if [ -x "$(which jhead)" ]
contact: Jan Huwald // Impressum