Skip to content

Commit 83bda2d

Browse files
committed
Address feedback from Zach
1 parent f328bcc commit 83bda2d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

.github/workflows/resize-images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: |
2121
# Find all image files that changed since last Monday
2222
CHANGED_IMAGES=$(git log --since="7 days ago" --name-only --pretty="" \
23-
-- '*.jpg' '*.jpeg' '*.png' | sort -u | tr '\n' ' ')
23+
-- '*.jpg' '*.jpeg' '*.png' '*.JPG' '*.JPEG' '*.PNG' | sort -u | tr '\n' ' ')
2424
2525
echo "changed_images=$CHANGED_IMAGES" >> $GITHUB_OUTPUT
2626
echo "Changed images: $CHANGED_IMAGES"

tools/resize_images.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ process_images() {
6565
}
6666

6767
# Skip if not an image file
68-
if [[ ! "$img" =~ \.(png|jpg|jpeg)$ ]]; then
68+
if [[ ! "$img" =~ \.(png|PNG|jpg|JPG|jpeg|JPEG)$ ]]; then
6969
if [[ "$img" == *.webp ]]; then
7070
echo "Skipping $img (already .webp)"
7171
continue
@@ -79,7 +79,7 @@ process_images() {
7979
width=$(identify -format "%w" "$img" 2>/dev/null || echo 0)
8080

8181
# Get file size in KB (macOS stat is different)
82-
filesize=$(stat -f%z "$img" 2>/dev/null || echo 0)
82+
filesize=$(stat -c%s "$img" 2>/dev/null || echo 0)
8383
kbsize=$((filesize / 1024))
8484

8585
# Define new filename
@@ -98,7 +98,7 @@ process_images() {
9898
echo "DRY RUN: Would update markdown references"
9999
else
100100
# Set quality dynamically based on file size
101-
if [ "$kbsize" -ge 1500 ]; then #150KB
101+
if [ "$kbsize" -ge 1500 ]; then #1500KB
102102
quality=80
103103
elif [ "$kbsize" -ge 500 ]; then # 500–1500KB
104104
quality=75
@@ -107,7 +107,7 @@ process_images() {
107107
fi
108108
echo "Optimizing $img (${kbsize}KB, ${width}px), quality=$quality"
109109
# Resize and convert to WebP. If error occurs, capture it and exit.
110-
error=$(magick "$img" -resize 1280x\> -quality $quality -define webp:lossless=true "$webp_img" 2>&1)
110+
error=$(magick "$img" -resize ${target_width}x\> -quality $quality -define webp:lossless=true "$webp_img" 2>&1)
111111
convert_status=$?
112112
if [ $convert_status -ne 0 ]; then
113113
echo "⚠️ Error converting $img to WebP format."

0 commit comments

Comments
 (0)