mcpField
I
image-optimization

image-optimization

github.com/secondskyDevelopment240596 installsUpdated 5w ago
Repository

About image-optimization

image-optimization is a web image optimization skill for developers. It covers format selection, responsive delivery, and a Sharp-based build example, along with size targets and a performance checklist.

Key features

  1. 01Format selection by image type
  2. 02Responsive image techniques
  3. 03Sharp-based WebP conversion
  4. 04Image size targets
  5. 05Optimization checklist

Use cases

  1. 01Preparing images for web pages
  2. 02Reducing image payload size
  3. 03Setting responsive image delivery

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/secondsky/claude-skills --skill image-optimization

After installing, type/image-optimizationin Claude Code to confirm it loaded.

Details

From the project README

Image Optimization

Optimize images for web performance with modern formats and responsive techniques.

Format Selection

FormatBest ForCompression
JPEGPhotosLossy, 50-70% reduction
PNGIcons, transparencyLossless, 10-30%
WebPModern browsers25-35% better than JPEG
AVIFNext-gen50% better than JPEG
SVGLogos, iconsVector, scalable

Responsive Images

<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img
    src="image.jpg"
    srcset="image-400.jpg 400w, image-800.jpg 800w, image-1200.jpg 1200w"
    sizes="(max-width: 600px) 100vw, 50vw"
    alt="Description"
    loading="lazy"
    decoding="async"
  >
</picture>

Lazy Loading

<!-- Native lazy loading -->
<img src="image.jpg" loading="lazy" alt="Description">

<!-- With blur placeholder -->
<img
  src="placeholder-blur.jpg"
  data-src="image.jpg"
  class="lazy"
  alt="Description"
>

Build Pipeline (Sharp)

const sharp = require('sharp');

async function optimizeImage(input, output) {
  await sharp(input)
    .resize(1200, null, { withoutEnlargement: true })
    .webp({ quality: 80 })
    .toFile(output);
}

Performance Targets

Asset TypeTarget Size
Hero image<200KB
Thumbnail<30KB
Total images<500KB

Optimization Checklist

  • Use WebP with JPEG fallback
  • Implement responsive srcset
  • Enable lazy loading for below-fold
  • Compress at quality 70-85
  • Serve from CDN
  • Set proper cache headers

Comments

Markdown supported