Image guides

Build a responsive image set from one photo

·

A responsive image set gives a browser several sizes of the same photo. Use the mug example to verify each width descriptor against an actual encoded file.

Multi-Resolution Compressor

Make three widths from the mug photo

Select Load example. Keep Widths at 128, 256, 384, Output format at WebP and Quality at 75. Generate variants from the 512 × 400 image.

Each width gets a height that preserves the displayed aspect ratio, rounded to a whole pixel. Verify the following output sizes.

Make three widths from the mug photo
Filename in the ZIPEncoded dimensionsWidth descriptor
image-background-mug-128w.webp128 × 100128w
image-background-mug-256w.webp256 × 200256w
image-background-mug-384w.webp384 × 300384w

ToolMellow mug example photoWHATWG HTML Standard, srcset attributes

Connect the files to your layout

Download the variants ZIP and open srcset.txt. Put the image files in the directory used by the markup, or update the candidate paths. Copy the list into the srcset attribute and set sizes to match the rendered layout.

Open variants.csv to check the actual byte count for each image. Test the smallest file where the layout is narrow and compare the details at larger sizes.

WHATWG HTML Standard, srcset attributes

Use the displayed dimensions of a different source

Add 640 to the widths and generate again. The mug source is 512 pixels wide, so the 640 px entry is marked as skipped and omitted from the ZIP and srcset.

For a transparent source, PNG and WebP can retain transparency. Use JPEG when a white backdrop fits the design. Keep the original file for future sizes.

WebP Container Specification

Common questions

Why is the height one pixel different from my calculation?

Each target height is rounded to the nearest whole source-proportional pixel, with at least one pixel in height.

Do I need the original file in the variants ZIP?

The ZIP packages the requested encoded variants, their srcset and a CSV report. Keep the original separately.

Sources

Put it into practice.

Related guides