Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/zsh
# $1 => Original Image
setopt extended_glob
infile="$1"
name="$2"
identify "$infile"
if [[ $(identify "$infile") == *" "(#b)(<->)x(<->)" "* ]]
then
h=$match[1]
w=$match[2]
if (( $h > $w ))
then
convert -geometry ${h}x${w} wmark/w.png wmark/tmp.png
else
convert -geometry ${h}x${w} wmark/h.png wmark/tmp.png
fi
composite -watermark 30% wmark/tmp.png "$infile" img/fig/_tmp_"$name".${(L)infile:e}
if (( $w > 1600 ))
then
convert -geometry 1600x img/fig/_tmp_"$name".${(L)infile:e} img/fig/"$name".${(L)infile:e}
rm img/fig/_tmp_"$name".${(L)infile:e}
else
mv img/fig/_tmp_"$name".${(L)infile:e} img/fig/"$name".${(L)infile:e}
fi
rm wmark/tmp.png
convert -geometry 400x img/fig/"$name".${(L)infile:e} img/thumb/"$name".${(L)infile:e}
else
print "Some error occured: Really it's image file?" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment