Created
December 3, 2012 07:18
-
-
Save jareware/4193332 to your computer and use it in GitHub Desktop.
Generates a "label image" for each JPEG matching INPUT_GLOB, writing them to OUTPUT_DIR.
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 | |
# Generates a "label image" for each JPEG matching INPUT_GLOB, writing them to OUTPUT_DIR. | |
# The labels contain the (possibly adjusted) timestamp of the EXIF tag of the input image. | |
# As the backgrounds are transparent, they can be overlaid on a timelapse, for example. | |
# Requires: exiftool imagemagick | |
INPUT_GLOB="*.JPG" | |
OUTPUT_DIR="labels" | |
ADD_SECONDS=0 # Number of seconds to adjust the original date with | |
LABEL_FORMAT="%H:%M" # See $ man strftime; "%a, %m.%d.%Y %H:%M:%S" -> "Sat, 11.10.2012 16:16:24" | |
COLOR="white" | |
FONT="Courier-Bold" # See $ convert -list font | |
FONT_SIZE="150" | |
RESOLUTION="3840x2880" | |
LOCATION="SouthEast" # See $ convert -list gravity | |
if [ ! -d "$OUTPUT_DIR" ]; then | |
echo "ERROR: Please create output directory \"$OUTPUT_DIR\" first" | |
exit 1 | |
fi | |
for FILE_IN in `ls -1 $INPUT_GLOB`; do | |
FILE_OUT=`echo "$OUTPUT_DIR/$FILE_IN" | sed "s/\..*\$/.png/"` | |
CREATE_DATE_S=`exiftool -d "%s" $FILE_IN | grep "Create Date" | cut -c 35-` | |
ACTUAL_DATE_S=`expr $CREATE_DATE_S + $ADD_SECONDS` | |
ACTUAL_DATE_F=`date -r $ACTUAL_DATE_S "+$LABEL_FORMAT"` | |
echo -n "$FILE_IN @ \"$ACTUAL_DATE_F\" -> $FILE_OUT ... " | |
convert -background transparent -fill $COLOR -font $FONT -size $RESOLUTION -gravity $LOCATION -pointsize $FONT_SIZE label:"$ACTUAL_DATE_F" $FILE_OUT 2> /dev/null | |
if [ $? -eq 0 ]; then | |
echo "OK" | |
else | |
echo "FAIL" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment