getzola/zola · error
Quality for WebP must be between {} and {} (inclusive); {} i
Error message
Quality for WebP must be between {} and {} (inclusive); {} is not valid What it means
`ImageFormat::from_args` validates WebP quality: when supplied, it must be within the inclusive range QUALITY_MIN_WEBP..=QUALITY_MAX_WEBP; omitting it (`None`) is allowed. Out-of-range values raise this error with the bounds and offending value.
Source
Thrown at components/imageproc/src/format.rs:54
("auto", false) => "png",
(other_format, _) => other_format,
};
match format_from_auto {
"jpeg" | "jpg" => match quality.unwrap_or(DEFAULT_QUALITY_JPEG) {
valid_quality @ QUALITY_MIN_JPEG..=QUALITY_MAX_JPEG => {
Ok(Jpeg { quality: valid_quality })
}
invalid_quality => Err(anyhow!(
"Quality for JPEG must be between {} and {} (inclusive); {} is not valid",
QUALITY_MIN_JPEG,
QUALITY_MAX_JPEG,
invalid_quality
)),
},
"png" => Ok(Png),
"webp" => match quality {
Some(QUALITY_MIN_WEBP..=QUALITY_MAX_WEBP) | None => Ok(WebP { quality }),
Some(invalid_quality) => Err(anyhow!(
"Quality for WebP must be between {} and {} (inclusive); {} is not valid",
QUALITY_MIN_WEBP,
QUALITY_MAX_WEBP,
invalid_quality
)),
},
"avif" => {
let q = match quality.unwrap_or(DEFAULT_QUALITY_AVIF) {
valid_quality @ QUALITY_MIN_AVIF..=QUALITY_MAX_AVIF => Ok(valid_quality),
invalid_quality => Err(anyhow!(
"Quality for AVIF must be between {} and {} (inclusive); {} is not valid",
QUALITY_MIN_AVIF,
QUALITY_MAX_AVIF,
invalid_quality
)),
}?;
let s = match speed.unwrap_or(DEFAULT_SPEED_AVIF) {
valid_speed @ SPEED_MIN_AVIF..=SPEED_MAX_AVIF => Ok(valid_speed),View on GitHub (pinned to 61d3082821)
Solutions
- Use an integer quality inside the WebP valid range (1-100), e.g. `--quality 75`
- Omit `--quality` entirely for WebP (None is accepted, encoding lossless/default)
- Check the imageproc format.rs constants QUALITY_MIN_WEBP/QUALITY_MAX_WEBP for the exact bounds
Example fix
// before $ zola image --format webp --quality 0.9 in.png out.webp // after $ zola image --format webp --quality 90 in.png out.webp
Defensive patterns
Strategy: validation
Validate before calling
if let Some(q) = quality {
if !(1..=100).contains(&q) {
return Err(format!("WebP quality must be 1-100, got {}", q));
}
} // None is valid for WebP Type guard
fn is_valid_webp_quality(q: Option<i32>) -> bool {
q.map_or(true, |v| (1..=100).contains(&v))
} Try / catch
match ImageFormat::from_args("webp", quality, None) {
Ok(f) => f,
Err(e) if e.to_string().contains("Quality for WebP") => {
eprintln!("Omit --quality or use an integer 1-100");
ImageFormat::WebP { quality: None }
}
Err(e) => return Err(e),
} Prevention
- For WebP, omitting quality is legal — prefer omitting unless tuning
- Convert 0-1 float quality to integer percent before passing
- Clamp quality into the valid range before calling from_args
When it happens
Trigger: Running `zola image --format webp --quality <n>` where n is outside the WebP bounds (e.g. 0, 150, or a fractional value like 0.9 that fails the integer range pattern).
Common situations: Using the 0.0-1.0 float convention from other encoders; assuming WebP allows values the JPEG path rejects or vice versa; copying quality from an ffmpeg/libwebp command line with different scale.
Related errors
- Quality for JPEG must be between {} and {} (inclusive); {} i
- Quality for AVIF must be between {} and {} (inclusive); {} i
- Speed for AVIF must be between {} and {} (inclusive); {} is
- Invalid filter type : {filter}. Valid values: nearest, trian
- `{}` is not an empty folder (hidden files are ignored).
AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03).
Data as JSON: /api/errors/0b2bd6833d7fd02b.
Report an issue: GitHub.