-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.sh
executable file
·44 lines (38 loc) · 1.54 KB
/
stack.sh
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
#!/bin/bash
# MagickStack - Kevin M Henderson 2023
WIDTH=1920 # max width only applies to vertical stack
HEIGHT=1080 # max height only applies to horizontal stack
STACK_VERTICAL=1 # 1=vertical 0=horizontal
FONT_SIZE=$(($HEIGHT/40)) # can replace with simple int (ex. 32)
FONT_GRAVITY=SouthEast #North, NorthWest, Center, East, SouthEast, South, etc.
JPG_QUALITY=50
DATE=$(date +"%Y-%m-%d")
if [ $STACK_VERTICAL -eq 1 ]; then ORIENTATION="-append"; else ORIENTATION="+append"; fi
for f in *
do # run only if dir contains >1 image
if [ -d "$f" -a $(find -iname "*.jpg" -o -iname "*.jpeg" | wc -l) -gt 1 ]; then
cd $f && mkdir temp
# copies all images into 'temp'
find -iname "*.jpg" -o -iname "*.jpeg" | xargs -I {} cp {} temp/
cd temp
for img in *
do
echo $f/$img
if [ $STACK_VERTICAL -eq 1 ]; then
RESIZE="$WIDTH"
else
RESIZE="x$HEIGHT"
fi
convert "$img" \
-auto-orient -resize $RESIZE \
-gravity $FONT_GRAVITY -pointsize $FONT_SIZE -fill black \
-annotate +2+2 %[exif:DateTimeOriginal] -fill white \
-annotate +2+$((2+$FONT_SIZE)) %[exif:DateTimeOriginal] \
"$img"
done
convert $ORIENTATION ./* -auto-orient -strip -interlace Plane -gaussian-blur 0.05 -quality $JPG_QUALITY% "$f"_"$DATE".jpg
mv "$f"_"$DATE".jpg ../../
echo "$f"_"$DATE".jpg
cd ..; rm -rf temp # cleanup and leave dir
fi
done