-
Notifications
You must be signed in to change notification settings - Fork 0
/
stitch.sh
33 lines (27 loc) · 841 Bytes
/
stitch.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
#!/bin/bash
# Default values for optional parameters
image1="1.png"
caption1="Before"
image2="2.png"
caption2="After"
# Parse command line arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--image1) image1="$2"; shift 2;;
--caption1) caption1="$2"; shift 2;;
--image2) image2="$2"; shift 2;;
--caption2) caption2="$2"; shift 2;;
*) echo "Unknown parameter: $1"; exit 1;;
esac
done
# Function to add captions to images
add_caption() {
local image="$1"
local caption="$2"
[ -f "$image" ] || { echo "File not found: $image"; return 1; }
filename="${image%.*}"
convert -gravity center "$image" -font Arial -pointsize 40 label:"$caption" +swap -append label:" " "$image"
}
add_caption "$image1" "$caption1"
add_caption "$image2" "$caption2"
convert -border 5 "$image1" "$image2" +append output.png