-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_backgrounds.sh
executable file
·36 lines (27 loc) · 1.16 KB
/
create_backgrounds.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
#!/bin/bash
# Create img and thumbs directories if they don't exist
mkdir -p img thumbs
# clear config
echo "" > config.json
# Loop through all .jpg files in the source directory
for file in ./source/*.jpg; do
# Get the filename without extension
filename=$(basename "$file" .jpg | tr '[:upper:]' '[:lower:]')
# Create scaled image with 1920x1080 pixels
convert "$file" -resize 1920x1080^ -gravity center -extent 1920x1080 "img/$filename.jpg"
# Create scaled image with 280x158 pixels
convert "$file" -resize 280x158^ -gravity center -extent 280x158 "thumbs/$filename.jpg"
# Add image information to config.json
echo ' {
"filetype": "jpg",
"id": "'"$filename"'",
"name": "'"$filename"'",
"src": "/evergreen-assets/backgroundimages/img/'"$filename"'.jpg",
"thumb_src": "/evergreen-assets/backgroundimages/thumbs/'"$filename"'.jpg"
},' >> config.json
done
# Remove the last comma from config.json
sed -i '$ s/,$//' config.json
# Add opening and closing brackets to config.json
sed -i '1s/^/{\n "videoBackgroundImages": [/' config.json
echo -e ' ]\n}' >> config.json