Change Image Quality
About the quality feature
What is it? Quality reduces the quality level of JPG and PNG images. Works with compression, resize, or crop.
| Level | File Size | Visual Impact |
|---|---|---|
| High (95%) | 813 KB | Original |
| Medium (80%) | ~650 KB | Minimal difference |
| Low (65%) | ~400 KB | Slight reduction |
| Custom (50%) | ~300 KB | Noticeable |
Enable quality
Quality is included in the Image Stack service. Configure via environment variables or query parameters.
Via environment variables
QUALITY_PRESET=high # 95% (default)
QUALITY_PRESET=medium # 80%
QUALITY_PRESET=low # 65%
QUALITY_PRESET=custom:75 # 1-100
PNG_LOSSLESS=true # PNG→WebP: lossless conversion (recommended)
PNG_LOSSLESS=false # PNG→WebP: lossy conversion with quality
Via query parameters
image.jpg?quality=80&fmt=webp
image.jpg?quality=76&crop=200,200
Where quality value is 1-100.
Quality behavior by format
| Format | Quality Support | Notes |
|---|---|---|
| JPEG | ✅ Fully Supported | Quality parameter works as expected |
| WebP | ✅ Supported (1‑93) | Values above 93 are clamped to 93 to keep libwebp stable under WASI. |
| PNG (no conversion) | ❌ Ignored | Always lossless, quality ignored |
| PNG→WebP (PNG_LOSSLESS=true) | ❌ Ignored | Lossless conversion, quality ignored |
| PNG→WebP (PNG_LOSSLESS=false) | ✅ Applied | Lossy conversion, quality applied |
Usage examples
<!-- JPEG with quality -->
<img src="photo.jpg?quality=80" alt="Photo" />
<!-- WebP (quality capped at 93) -->
<img src="photo.jpg?quality=95&fmt=webp" alt="Photo" />
<!-- Resize + quality -->
<img src="photo.jpg?width=800&quality=80" alt="Photo" />
<!-- Crop + quality -->
<img src="photo.jpg?crop=16:9&quality=80" alt="Photo" />
<!-- Full transformation -->
<img src="photo.jpg?width=1200&crop=16:9&quality=85&fmt=webp" alt="Photo" />
Check HTTP headers
curl -I https://your-cdn.com/image.jpg?quality=80&fmt=webp
Expected headers:
Content-Type: image/webpX-Img-Operations: conversion
Limitations
WebP quality clamp
- WebP lossy encoding now runs via libwebp inside WASI, but values above ~93 frequently exhaust linear memory.
- Requests above 93 are automatically clamped to 93 and a warning is logged.
- When
PNG_LOSSLESS=true, PNG inputs still take the pure-Rust lossless path, so quality is skipped in that specific case.
See limitations.md for details.
Recommended configuration
QUALITY_PRESET=high
PNG_LOSSLESS=true
CONVERT_TO_WEBP=true
See also
- Compression Tool (WebP) - Format conversion
- Resize Images Tool - Change image dimensions
- Crop Images Tool - Cut out image areas
- Limitations - Detailed limitations documentation