Skip to content

Commit f328bcc

Browse files
committed
Enable lossless conversion and adjust quality scaling
1 parent c056e85 commit f328bcc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tools/resize_images.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,16 @@ process_images() {
9898
echo "DRY RUN: Would update markdown references"
9999
else
100100
# Set quality dynamically based on file size
101-
if [ "$kbsize" -ge 15000 ]; then #15MB
102-
quality=50
103-
elif [ "$kbsize" -ge 5000 ]; then # 5–15MB
104-
quality=70
105-
else # < 5MB
106-
quality=85
101+
if [ "$kbsize" -ge 1500 ]; then #150KB
102+
quality=80
103+
elif [ "$kbsize" -ge 500 ]; then # 500–1500KB
104+
quality=75
105+
else # < 500KB
106+
quality=95
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 "$webp_img" 2>&1)
110+
error=$(magick "$img" -resize 1280x\> -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)