@@ -21,7 +21,8 @@ FILENAME="${FILENAME%.webp}"
2121FILENAME=" ${FILENAME% .png} "
2222
2323# Find the latest screenshot - check custom location first, then Desktop
24- LATEST_SCREENSHOT=$( ls -t ~ /Documents/Screenshots/Screen* .png ~ /Desktop/Screen* .png 2> /dev/null | head -1)
24+ # Check for both WebP and PNG files
25+ LATEST_SCREENSHOT=$( ls -t ~ /Documents/Screenshots/* .{webp,png} ~ /Desktop/* .{webp,png} 2> /dev/null | head -1)
2526
2627if [ -z " $LATEST_SCREENSHOT " ]; then
2728 echo " ❌ Error: No screenshots found in ~/Documents/Screenshots/ or ~/Desktop/"
@@ -35,15 +36,20 @@ mkdir -p "$PROJECT_ROOT/docs/img"
3536
3637OUTPUT_FILE=" $PROJECT_ROOT /docs/img/$FILENAME .webp"
3738
38- # Convert PNG to WebP using cwebp (as suggested by lint)
39- echo " Converting to WebP..."
40- if ! command -v cwebp & > /dev/null; then
41- echo " ❌ Error: cwebp not found. Install with: brew install webp"
42- exit 1
39+ # Check if the screenshot is already WebP
40+ if [[ " $LATEST_SCREENSHOT " == * .webp ]]; then
41+ echo " Using existing WebP file..."
42+ cp " $LATEST_SCREENSHOT " " $OUTPUT_FILE "
43+ else
44+ # Convert PNG to WebP using cwebp
45+ echo " Converting PNG to WebP..."
46+ if ! command -v cwebp & > /dev/null; then
47+ echo " ❌ Error: cwebp not found. Install with: brew install webp"
48+ exit 1
49+ fi
50+ cwebp " $LATEST_SCREENSHOT " -o " $OUTPUT_FILE " -q 85
4351fi
4452
45- cwebp " $LATEST_SCREENSHOT " -o " $OUTPUT_FILE " -q 85
46-
4753# Remove the original screenshot
4854rm " $LATEST_SCREENSHOT "
4955
0 commit comments