Last active
March 24, 2019 05:22
-
-
Save vtta/534af36efc97c148f43c3840d3e9b437 to your computer and use it in GitHub Desktop.
A bash script to watermark all the photos in a folder. ImageMagick is required.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SRC_DIR="${1}" | |
MARK="${2}" | |
if [[ "$#" -lt "2" ]] ; then | |
echo "A small script for adding watermark to images." | |
echo "Usage: $0 INPUT_IMAGE_FOLDER WATER_MARK_FILE" | |
exit 1 | |
fi | |
OUT_DIR="${1}.marked" | |
mkdir -p "${OUT_DIR}" | |
# MARK_SIZE=$(identify ${MARK} | cut -d " " -f3) | |
# MARK_WIDTH=$(echo ${MARK_SIZE} | cut -d "x" -f1) | |
# MARK_HEIGHT=$(echo ${MARK_SIZE} | cut -d "x" -f2) | |
find "${SRC_DIR}" -type f -print0 | while IFS= read -r -d '' IMG; do | |
FULLNAME=`basename "${IMG}"` | |
FNAME="${FULLNAME%.*}" | |
# EXT="${FULLNAME##*.}" | |
echo "Processing $FNAME" | |
# read line </dev/tty # waite for enter | |
convert "${IMG}" -auto-orient \ | |
"${MARK}" -gravity SouthEast \ | |
-composite "${OUT_DIR}/${FULLNAME}" | |
done | |
echo "Finished" | |
echo "Opening output folder" | |
open "${OUT_DIR}" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment