I have a large directory tree with many sub-folders and lots of images within each one. I found a script that applies watermark to all images within a directory, in-place, overwriting the original image. I'm looking for the best way to iterate trough all the folders and subfolders and run the "compose" command for each image on my linux server. Here is the original script I found
#!/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=$HOME/public_html/image/catalog/logo-website/watermark.png # This is the path to your watermark image
SCALE=100 # 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
composite -dissolve 40% -gravity SouthEast -quality 100 \( $WM -resize $SCALE% \) "$IMAGE" "$IMAGE"
done
else
echo exiting
exit 0
fi
exit 0
Should I use a combination of "find . -name *.jpg" or something else?