Created
November 29, 2015 14:43
-
-
Save mcamiano/8e1c62c66b446365d1a9 to your computer and use it in GitHub Desktop.
Unload photos from flash card, reduce JPGs to roughly HD size, and apply watermarks; requires imagemagick; assumes OSX bash shell environment
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 | |
if test -f ~/.unloadshots | |
then | |
. ~/.unloadshots # Environment | |
fi | |
SOURCEMEDIAFOLDER=${UNLOADMEDIAFOLDER:-/Volumes/Untitled/DCIM} | |
TARGETMEDIAFOLDER=${LOADMEDIAFOLDER:-~/Pictures} | |
WATERMARK=${LOADWATERMARK:-© 2014 by Mitch C. Amiano} | |
if [[ ! -d ${SOURCEMEDIAFOLDER} ]] | |
then | |
echo "Arggggghhh... there is no folder at ${SOURCEMEDIAFOLDER}. You need to plug a card in or change \$UNLOADMEDIAFOLDER. Bailing out." | |
exit 1 | |
fi | |
echo "Unloading camera shots. Please select source folder on media card (enter the number):" | |
select folder in $(/bin/ls -d ${SOURCEMEDIAFOLDER}/*/) "Quit" | |
do | |
if [[ ${folder} = "Quit" || ${folder} = "" ]] | |
then | |
echo "OK, Quitting." >&2 | |
exit | |
fi | |
if [[ ! -z "$folder" ]] | |
then | |
location=$folder | |
break | |
else | |
echo "That selection is not a folder. Quitting..." >&2 | |
exit 1 | |
fi | |
done | |
echo "Loading photos" | |
# make a name out of the original media folder name, with the last modification date tacked on to disambigute potential folder name clashes | |
lastmoddate=$(stat -f "%Sm"| cut -d " " -f1,2,4 | /usr/bin/sed 's/[ ]/_/g') | |
target=${TARGETMEDIAFOLDER}/$(basename ${location%/}).${lastmoddate} | |
if [[ -d ${target} ]] | |
then | |
echo "Target folder ${target} exists already. Rename or remove it first. Bailing out!" >&2 | |
exit | |
fi | |
mkdir -p ${target} | |
cd ${target} | |
echo "Copying all source photos..." | |
cp ${location}* . | |
mkdir -p small | |
echo "Scaling JPG shots to moderate resolution 1920x? versions..." | |
sips -Z 1920 ./DSC_*.JPG --out small 2>/dev/null 1>/dev/null & | |
cd small | |
echo "Stamping copyright watermark on the moderate resolution versions..." | |
mkdir copy | |
function getposition() { | |
positions=(northwest northeast southwest southeast center) | |
placeat=${positions[$RANDOM % ${#positions[@]} ]} | |
echo $placeat | |
} | |
find . -name "*.JPG" -type f | while read file | |
do | |
convert $file -pointsize 48\ | |
-font Palatino-Bold -stroke 'rgba(255,255,255,0.10)' -fill 'rgba(0,0,0,0.15)'\ | |
-gravity $(getposition)\ | |
-annotate +200+200 "${WATERMARK}" -fill 'rgba(200,200,200,0.1)'\ | |
-annotate +199+199 "${WATERMARK}"\ | |
copy/$file | |
done | |
echo "Imported to $target" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment