getzola/zola · error
Quality for AVIF must be between {} and {} (inclusive); {} i
Error message
Quality for AVIF must be between {} and {} (inclusive); {} is not valid What it means
`ImageFormat::from_args` validates AVIF quality: when the `--quality` flag is supplied for format `avif`, it must fall in the inclusive range QUALITY_MIN_AVIF..=QUALITY_MAX_AVIF; a default (DEFAULT_QUALITY_AVIF) applies when omitted. Out-of-range values raise this error with bounds and the offending value.
Source
Thrown at components/imageproc/src/format.rs:64
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),
invalid_speed => Err(anyhow!(
"Speed for AVIF must be between {} and {} (inclusive); {} is not valid",
SPEED_MIN_AVIF,
SPEED_MAX_AVIF,
invalid_speed
)),
}?;
Ok(Avif { quality: q, speed: s })
}
_ => Err(anyhow!("Invalid image format: {}", format)),View on GitHub (pinned to 61d3082821)
Solutions
- Pass an integer quality within the AVIF bounds defined in components/imageproc/src/format.rs (check QUALITY_MIN_AVIF/QUALITY_MAX_AVIF)
- Omit `--quality` to use DEFAULT_QUALITY_AVIF
- Convert 0-1 float quality to the accepted integer scale
Example fix
// before $ zola image --format avif --quality 0.6 in.png out.avif // after $ zola image --format avif --quality 60 in.png out.avif
Defensive patterns
Strategy: validation
Validate before calling
let q = quality.unwrap_or(DEFAULT_QUALITY_AVIF);
if !(QUALITY_MIN_AVIF..=QUALITY_MAX_AVIF).contains(&q) {
return Err(format!("AVIF quality must be {}-{}, got {}", QUALITY_MIN_AVIF, QUALITY_MAX_AVIF, q));
} Type guard
fn is_valid_avif_quality(q: i32) -> bool {
(QUALITY_MIN_AVIF..=QUALITY_MAX_AVIF).contains(&q)
} Try / catch
match ImageFormat::from_args("avif", quality, speed) {
Ok(f) => f,
Err(e) if e.to_string().contains("Quality for AVIF") => {
eprintln!("Falling back to default AVIF quality");
ImageFormat::from_args("avif", None, speed)?
}
Err(e) => return Err(e),
} Prevention
- Check QUALITY_MIN_AVIF/QUALITY_MAX_AVIF constants for exact bounds instead of assuming 1-100
- Use the default quality unless you have a specific size/quality target
- Never pass encoder-specific scales (rav1e/aom) directly
When it happens
Trigger: Running `zola image --format avif --quality <n>` where n is outside the AVIF quality bounds (e.g. 0 or >100, or a float like 0.6).
Common situations: Reusing AVIF encoder conventions from rav1e/aom (where quality/speed scales differ); passing a fractional 0-1 quality; copying a quality value valid for WebP/JPEG but outside AVIF bounds in this tool.
Related errors
- Speed for AVIF must be between {} and {} (inclusive); {} is
- Quality for JPEG must be between {} and {} (inclusive); {} i
- Quality for WebP must be between {} and {} (inclusive); {} i
- 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/cc2d1bc1c0949715.
Report an issue: GitHub.