ImageMagick:强大的图像编辑脚本工具
保护在线图像
在网络上发布图像时,想要保护图像内容不被随意复制是很困难的。因为计算机渲染在线图像时会使用设备的图像缓冲区,通过屏幕截图等工具就可以复制图像。不过,我们可以采取两种方法来一定程度上保护在线图像:
- 只发布小尺寸的图像,专业摄影师的网站通常只分享缩略图,目的是引导用户购买大尺寸的图像文件。
- 给图像添加水印。使用 ImageMagick 可以轻松地批量添加水印。
以下是添加水印的脚本:
#!/bin/bash # watermark--Adds specified text as a watermark on the input image, # saving the output as image+wm wmfile="/tmp/watermark.$$.png" fontsize="44" # Should be a starting arg trap "$(which rm) -f $wmfile" 0 1 15 # No temp file left behind if [ $# -ne 2 ] ; then echo "Usage: $(basename $0) imagefile \"watermark text\"" >&2 exit 1 fi if [ ! -r "$1" ] ; then echo "$(basename $0): Can't read input image $1" >&2 exit 1 fi #