Skip to content

Commit 5d4efd0

Browse files
committed
Added optimization script and fixed navbar to top
1 parent 3214edf commit 5d4efd0

File tree

15 files changed

+53
-13
lines changed

15 files changed

+53
-13
lines changed

optimize-images.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# Base directories
4+
SOURCE_BASE="public"
5+
WEBP_BASE="public/webp"
6+
7+
# Create WebP base directory if it doesn't exist
8+
mkdir -p "$WEBP_BASE"
9+
10+
# Function to process images in a directory
11+
process_directory() {
12+
local dir="$1"
13+
14+
# Create corresponding WebP directory
15+
local rel_path="${dir#$SOURCE_BASE/}"
16+
local webp_dir="$WEBP_BASE/$rel_path"
17+
mkdir -p "$webp_dir"
18+
19+
# Process all images in this directory
20+
for file in "$dir"/*.{png,jpg,jpeg}; do
21+
# Skip if no matches were found
22+
[ -f "$file" ] || continue
23+
24+
filename=$(basename -- "$file")
25+
name="${filename%.*}"
26+
27+
echo "Processing: $file"
28+
29+
# Convert to WebP with 80% quality and save to WebP directory
30+
magick "$file" -resize "800x800>" -quality 80 "$webp_dir/$name.webp"
31+
32+
# Also optimize original in place
33+
magick "$file" -resize "800x800>" -quality 80 "$file"
34+
done
35+
}
36+
37+
# Find all directories under public/images and process each
38+
find "$SOURCE_BASE/images" -type d | while read -r dir; do
39+
process_directory "$dir"
40+
done
41+
42+
echo "Image optimization complete!"

public/images/.DS_Store

0 Bytes
Binary file not shown.

public/images/blog/.DS_Store

0 Bytes
Binary file not shown.
-883 KB
Loading
-1.1 MB
Loading
-819 KB
Loading
-30.8 KB
Loading
55.3 KB
Loading
66.6 KB
Loading
82.9 KB
Loading

0 commit comments

Comments
 (0)