Skip to content

Instantly share code, notes, and snippets.

@reasonset
Created March 12, 2016 05:37
Show Gist options
  • Save reasonset/c8ddd935e5561d2bc1b8 to your computer and use it in GitHub Desktop.
Save reasonset/c8ddd935e5561d2bc1b8 to your computer and use it in GitHub Desktop.
#!/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