Tutorial6 min read·Updated

Rails Active Storage: Prefer WebP Variants

Active Storage variants can request `format: :webp`. That still processes the blob you attached. Convert marketing images in `app/assets` to WebP, and attach user photos after a resize so variants are cheap.

Blobs are forever until you purge them

A 12 MP JPEG blob stays on S3. Variants are extras. A pre-resized WebP blob reduces storage and variant time.

Why it matters

  • S3 + CloudFront bills track origin size.
  • Variant generation on first view delays LCP.
  • Propshaft/Sprockets will ship PNG if that is what you committed.

How to do it

  1. Convert asset pipeline images.
  2. For uploads, resize_to_limit: [2000, 2000] then WebP quality 80.
  3. Use image_tag with srcset helpers you already have.

Settings that work

2000 px cap. Quality 80. Keep PNG only for lossless UI in emails if required.

Convert a batch in your browser. Nothing is uploaded.

Put it into practice

Convert your images to WebP right now, free and privately in your browser.

Open the converter

Frequently asked questions

Yes, with Vips/ImageMagick. Check your variant processor.

Only if you need print-quality originals. Most apps should not.

Keep reading

Tutorial6 min read

WebP in Laravel

Convert marketing assets to WebP locally, and convert user uploads with Intervention or the Fast WebP API.

Read more
Tutorial6 min read

WebP in Django

Django ImageField stores what you upload. Convert static assets to WebP and normalise uploads with Pillow or an API.

Read more
Workflow6 min read

Product photos to WebP

Studio JPEGs are too big for product pages. Bulk convert catalogue photos to WebP with widths that match your PDP and PLP.

Read more