Ship fast product galleries and editorial visuals
Pair this skill directly with Workflow 12: E-Commerce Catalog Packshot and 3D GLB Batch and Guide 09: AI Image Craft, Vector SVGs and Brand Design Systems.
SKILL.md Install into .claude/skills/, .cursor/skills/, or .agents/skills/ so your coding agent automatically compiles lightweight responsive WebP/AVIF sets with CLS = 0 markup whenever you add images.
Installable SKILL.md teaching Claude Code, Cursor, and Codex to batch-convert raw AI PNG renders (FLUX 3 Image, Seedream 5.5, Ideogram 4.6, OpenAI GPT-Image-2.6) into responsive 640px, 1280px, and 1920px WebP and AVIF assets using Node.js sharp—stripping EXIF bloat, preserving alpha cutouts, and emitting exact width, height, srcset, and LCP loading attributes.
Choose Claude Code, Cursor, or Codex below to install SKILL.md from /raw/skills/.
Ask it to process ./raw-assets/ into responsive 640px, 1280px, and 1920px WebP + AVIF deliverables.
<picture> markup with exact dimensions Auto-emits width, height, srcset, sizes, and fetchpriority so Core Web Vitals stay green (CLS = 0).
Pick the app you use below for the exact verified command or config—zero manual guessing.
.claude/skills/sharp-responsive-images/SKILL.md for automated responsive WebP/AVIF encoding. mkdir -p .claude/skills/sharp-responsive-images
curl -fsSL https://framesfield.com/raw/skills/sharp-responsive-webp-image-pipeline-skill -o .claude/skills/sharp-responsive-images/SKILL.md .cursor/skills/ for frontend & Astro/Next.js repositories. mkdir -p .cursor/skills/sharp-responsive-images
curl -fsSL https://framesfield.com/raw/skills/sharp-responsive-webp-image-pipeline-skill -o .cursor/skills/sharp-responsive-images/SKILL.md .agents/skills/ directory across compatible agents. mkdir -p .agents/skills/sharp-responsive-images
curl -fsSL https://framesfield.com/raw/skills/sharp-responsive-webp-image-pipeline-skill -o .agents/skills/sharp-responsive-images/SKILL.md
This is the exact raw file served at /raw/skills/sharp-responsive-webp-image-pipeline-skill.
---
name: sharp-responsive-images
description: Batch-optimize raw AI image exports (PNG/JPG) into responsive 640px, 1280px, and 1920px WebP and AVIF assets using Node.js sharp, preserving alpha transparency where present, enforcing Core Web Vitals file budgets, and writing zero-CLS <picture>/<img> markup with exact numeric dimensions.
---
# Sharp Responsive WebP & AVIF Image Pipeline Protocol
Never commit multi-megabyte raw PNG outputs straight from FLUX 3 Image, Seedream 5.5, Ideogram 4.6, or GPT-Image-2.6 into `public/`. Whenever adding raster photos, packshots, or hero artwork to a website, execute this deterministic pipeline:
## 1. Verified Sharp Responsive Batch Script (ESM)
Keep original lossless `.png` masters outside `public/` (e.g., `assets-raw/`), and compile responsive breakpoints with `withoutEnlargement: true` and `.rotate()` (auto-applies EXIF orientation and strips metadata bloat):
```js
import { readdirSync, mkdirSync } from 'node:fs';
import { parse, join } from 'node:path';
import sharp from 'sharp';
const IN_DIR = './assets-raw';
const OUT_DIR = './public/images/media';
const WIDTHS = [640, 1280, 1920];
mkdirSync(OUT_DIR, { recursive: true });
for (const file of readdirSync(IN_DIR).filter((f) => /\.(png|jpe?g|webp)$/i.test(f))) {
const { name } = parse(file);
const input = join(IN_DIR, file);
const meta = await sharp(input).metadata();
const hasAlpha = Boolean(meta.hasAlpha);
for (const w of WIDTHS) {
if (meta.width && w > meta.width && w !== WIDTHS[0]) continue;
const base = sharp(input).rotate().resize({ width: w, withoutEnlargement: true });
const webpInfo = await base.clone().webp({ quality: hasAlpha ? 90 : 84, alphaQuality: 95, effort: 5 }).toFile(join(OUT_DIR, `${name}-${w}.webp`));
const avifInfo = await base.clone().avif({ quality: 58, effort: 4 }).toFile(join(OUT_DIR, `${name}-${w}.avif`));
console.log(`${name}-${w}: ${webpInfo.width}x${webpInfo.height} | WebP ${(webpInfo.size / 1024).toFixed(1)}KB | AVIF ${(avifInfo.size / 1024).toFixed(1)}KB`);
}
}
```
## 2. File-Weight Budgets by Slot
- **Above-the-fold Hero (`1280px–1920px`):** Target `< 180 KB` WebP (`< 120 KB` AVIF).
- **PDP Square / Card Thumbnail (`640px–1200px`):** Target `< 90 KB` WebP (`< 65 KB` AVIF).
- **Alpha Cutouts (`Seedream 5.5`, `Ideogram 4.6`, `GPT-Image-2.6`, `Bria RMBG`):** Preserve crisp alpha edges (`alphaQuality: 95` WebP or `png({ compressionLevel: 9, palette: false })`); never convert transparent PNGs to JPEG.
- **Charts / Diagrams with Sharp Text:** Use `webp({ quality: 92 })` (never aggressive lossy compression that introduces halo ringing around thin typography).
## 3. Mandatory Zero-CLS `<picture>` / `<img>` Markup Contract
Always emit exact natural pixel `width` and `height` from `sharp` output metadata plus descriptive `alt` text (`10–35` words):
```html
<picture>
<source type="image/avif" srcset="/images/media/hero-640.avif 640w, /images/media/hero-1280.avif 1280w" sizes="(max-width: 768px) 100vw, 1200px" />
<source type="image/webp" srcset="/images/media/hero-640.webp 640w, /images/media/hero-1280.webp 1280w" sizes="(max-width: 768px) 100vw, 1200px" />
<img src="/images/media/hero-1280.webp" width="1280" height="720" alt="Studio stoneware pour-over kettle on travertine counter under 5600K daylight" loading="eager" fetchpriority="high" decoding="async" class="w-full h-auto" />
</picture>
```
- Use `loading="eager" fetchpriority="high"` **ONLY** for the single above-the-fold LCP hero.
- Use `loading="lazy" decoding="async"` for every below-the-fold image. "Optimize the 6 raw FLUX 3 Image product PNGs in ./assets-raw/ into 640px and 1280px WebP/AVIF sets in public/images/products/ and update ProductGallery.astro with zero-CLS <picture> tags."
- Runs sharp batch script encoding 640w + 1280w WebP and AVIF files (cutting 14.2 MB raw PNGs down to 680 KB total across all WebP variants). - Preserves alpha transparency on the GPT-Image-2.6 studio cutout at alphaQuality: 95. - Updates ProductGallery.astro with exact numeric width/height attributes, fetchpriority="high" on Hero 01, and loading="lazy" on secondary shots.
sharp installed (npm i -D sharp)public/ if the same frames will later feed Image-to-Video models or 300 DPI print upscalingPair this skill directly with Workflow 12: E-Commerce Catalog Packshot and 3D GLB Batch and Guide 09: AI Image Craft, Vector SVGs and Brand Design Systems.