+ # resize and distort
+ 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"
+ 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"
+ fi