linux中如何批量给照片加注水印
由于要上传照片,想加上自己的水印,google了一番, linux 有一个非常好用的工具可以用来进行图片合成,包括加水印。非常方便使用。
网友有开发了bash脚本,可以方便的批量加水印。经过我的测试,如下脚本运行正常。 但是在使用之前,一定要确保你安装了composite 命令哦。 此命令包含在 ImageMagick的包中,安装ImageMagick 即可。
yum install -y ImageMagick
#!/bin/bash
###########################################
# NAME: wn-ow
# AUTHOR: Linerd (http://tuxtweaks.com), Copyright 2009
# LICENSE: Creative Commons Attribution – Share Alike 3.0 http://creativecommons.org/licenses/by-sa/3.0/
# You are free to use and/or modify this script. If you choose to distribute this script, with or
# without changes, you must attribute credit to the author listed above.
# REQUIRES: ImageMagick, coreutils
# VERSION: 1.0
# DESCRIPTION: A script to add a watermark and overwrite all images in a directory.
#
# This script will watermark all of the images in a directory. Warning! This will overwrite the files.
###########################################
# Initialize variables
WM=/work/my/picture/wartermark.png # This is the path to your watermark image
SCALE=400 # This sets the scale % of your watermark image
# Warning
echo -e “This will overwrite all of the images in this directory.”\\n”Are you shure want to continue? {Y/n}”
read REPLY
if
[ “$REPLY” != “n” ] && [ “$REPLY” != “N” ]
then
file -i * | grep image | awk -F’:’ ‘{ print $1 }’ | while read IMAGE
do
echo Watermarking $IMAGE
echo composite -dissolve 40% -gravity center -quality 100 \( $WM -resize $SCALE% \) “$IMAGE” “$IMAGE”
composite -dissolve 40% -gravity center -quality 100 \( $WM -resize $SCALE% \) “$IMAGE” “$IMAGE”
done
else
echo exiting
exit 0
fi
exit 0
此篇文章已被阅读2161 次