-
Notifications
You must be signed in to change notification settings - Fork 0
/
timestamp
executable file
·60 lines (49 loc) · 1.6 KB
/
timestamp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#Original script from http://dptnt.com/2009/08/add-date-time-stamp-to-jpeg-photos-using-free-software-mac-linux-nix-edition/
#Thanks to the original author!
if [ $# -eq 0 ]
then
cat << _EOF_
USAGE: $0 file1 file2 ..., or
$0 *.jpg, or
$0 dir/*.jpg
...
_EOF_
exit
fi
while [ "$1" != "" ]; do
# Skip directories
if [ -d "$1" ]; then
shift
continue
fi
# Skip already converted files (may get overwritten)
if [[ $1 == *_DT* ]]
then
echo "------ Skipping: $1"
shift
continue
fi
# Work out a new file name by adding "_DT" before file extension
file=$1
echo "###### Working on file: $file"
filename=${file%.*}
extension=${file##*.}
output=${filename}_DT.${extension}
# Get the file dimension
dim=$(identify -format "%w %h" "$file")
width=${dim%% *}
height=${dim#* }
# Decide the font size automatically
if [ $width -ge $height ]
then
pointsize=$(($width/80))
else
pointsize=$(($height/80))
fi
echo " Width: $width, Height: $height. Using pointsize: $pointsize"
# The real deal here
convert "$file" -gravity SouthEast -pointsize $pointsize -stroke black -strokewidth 4 -annotate +$pointsize+$pointsize "%[exif:DateTimeOriginal]" -stroke white -strokewidth 1 -fill white -annotate +$pointsize+$pointsize "%[exif:DateTimeOriginal]" "$output"
shift
done
exit 0