Scan and compress oversized images in the assets directory. Use this skill when the user wants to optimize images, reduce file sizes, check for large assets, compress blog images, find unused images, or optimize the site for performance. Also trigger when the user mentions slow page loads, large images, or asset optimization.
Scan assets/ for oversized images, report file sizes, and compress images that exceed thresholds.
Images in assets/ are served directly via GitHub Pages with no CDN compression. Large images slow down page loads. This skill scans, reports, and compresses oversized files.
| Image type | Max size | Pattern |
|---|---|---|
| Blog cover images | 400 KB | assets/blog/*-cover.png |
| Blog inline images | 300 KB | assets/blog/*-inline-*.* |
| Other images | 500 KB | Everything else in assets/ |
Use Python to scan and report:
import os, glob
for pattern in ['assets/**/*.png', 'assets/**/*.jpg', 'assets/**/*.jpeg', 'assets/**/*.gif', 'assets/**/*.webp']:
for f in glob.glob(pattern, recursive=True):
size_kb = os.path.getsize(f) / 1024
print(f'{size_kb:8.0f} KB {f}')
Skip SVG files (vector, already optimized) and favicon files (assets/favicon/).
# Image Asset Report
## Blog Cover Images (threshold: 400 KB)
403 KB assets/blog/example-cover.png [OVER]
334 KB assets/blog/other-cover.png [OK]
## Blog Inline Images (threshold: 300 KB)
58 KB assets/blog/example-inline-1.jpeg [OK]
## Other Images (threshold: 500 KB)
238 KB assets/images/feature.png [OK]
Total images: {count}
Total size: {total} MB
Over threshold: {count} images
Present oversized images and offer:
PNG cover images (must stay square):
from PIL import Image
img = Image.open(path)
if img.width > 512 or img.height > 512:
img = img.resize((512, 512), Image.LANCZOS)
img.save(path, "PNG", optimize=True)
JPEG inline images:
from PIL import Image
img = Image.open(path)
if img.width > 1200:
ratio = 1200 / img.width
img = img.resize((1200, int(img.height * ratio)), Image.LANCZOS)
img.save(path, optimize=True, quality=85)
PNG inline images (non-cover):
from PIL import Image
img = Image.open(path)
if img.width > 1200:
ratio = 1200 / img.width
img = img.resize((1200, int(img.height * ratio)), Image.LANCZOS)
img.save(path, "PNG", optimize=True)
# Compression Results
| File | Before | After | Saved |
|------|--------|-------|-------|
| assets/blog/example-cover.png | 450 KB | 380 KB | 70 KB (16%) |
Total saved: {total} KB
If the user requests it:
assets/.html and .md files for the filenameblog/posts.json image fields (blog covers are referenced there)Warning: Some images may be referenced dynamically — present results but don't auto-delete.