File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,17 @@ process_images() {
9797 echo " DRY RUN: Would remove $img "
9898 echo " DRY RUN: Would update markdown references"
9999 else
100- echo " Optimizing $img (${kbsize} KB, ${width} px)"
101-
100+ # Set quality dynamically based on file size
101+ if [ " $kbsize " -ge 15000 ]; then # ≥ 15MB
102+ quality=30
103+ elif [ " $kbsize " -ge 5000 ]; then # 5–15MB
104+ quality=50
105+ else # < 5MB
106+ quality=75
107+ fi
108+ echo " Optimizing $img (${kbsize} KB, ${width} px), quality=$quality "
102109 # Resize and convert to WebP. If error occurs, capture it and exit.
103- error=$( magick " $img " -resize 1280x\> -quality 85 " $webp_img " 2>&1 )
110+ error=$( magick " $img " -resize 1280x\> -quality $quality " $webp_img " 2>&1 )
104111 convert_status=$?
105112 if [ $convert_status -ne 0 ]; then
106113 echo " ⚠️ Error converting $img to WebP format."
You can’t perform that action at this time.
0 commit comments