-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanner.sh
More file actions
executable file
·34 lines (25 loc) · 845 Bytes
/
Copy pathbanner.sh
File metadata and controls
executable file
·34 lines (25 loc) · 845 Bytes
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
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <input_file>"
exit 1
fi
# Input file name provided as an argument
input_file="$1"
# Check if the input file exists
if [ ! -f "$input_file" ]; then
echo "Error: Input file '$input_file' not found."
exit 1
fi
# Extract filename without path and extension
filename=$(basename -- "$input_file")
# filename="${filename%.*}"
filename="${filename%%_*}"
# Generate a temporary file name for intermediate results
temp_file="tmp/result_temp.png"
# Scale the image to the specified width
convert "$input_file" -resize 768x "$temp_file"
# Crop the image to the specified height (centered)
convert "$temp_file" -gravity center -crop x150+0+0 "web/media/$filename.png"
rm "$temp_file"
echo "Banner saved as 'web/media/$filename.png'."