{"record":{"id":"907473185d1a509c","repo":"getzola/zola","slug":"speed-for-avif-must-be-between-and-inclusiv","errorCode":null,"errorMessage":"Speed for AVIF must be between {} and {} (inclusive); {} is not valid","messagePattern":"Speed for AVIF must be between (.+?) and (.+?) \\(inclusive\\); (.+?) is not valid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/imageproc/src/format.rs","lineNumber":73,"sourceCode":"                    \"Quality for WebP must be between {} and {} (inclusive); {} is not valid\",\n                    QUALITY_MIN_WEBP,\n                    QUALITY_MAX_WEBP,\n                    invalid_quality\n                )),\n            },\n            \"avif\" => {\n                let q = match quality.unwrap_or(DEFAULT_QUALITY_AVIF) {\n                    valid_quality @ QUALITY_MIN_AVIF..=QUALITY_MAX_AVIF => Ok(valid_quality),\n                    invalid_quality => Err(anyhow!(\n                        \"Quality for AVIF must be between {} and {} (inclusive); {} is not valid\",\n                        QUALITY_MIN_AVIF,\n                        QUALITY_MAX_AVIF,\n                        invalid_quality\n                    )),\n                }?;\n                let s = match speed.unwrap_or(DEFAULT_SPEED_AVIF) {\n                    valid_speed @ SPEED_MIN_AVIF..=SPEED_MAX_AVIF => Ok(valid_speed),\n                    invalid_speed => Err(anyhow!(\n                        \"Speed for AVIF must be between {} and {} (inclusive); {} is not valid\",\n                        SPEED_MIN_AVIF,\n                        SPEED_MAX_AVIF,\n                        invalid_speed\n                    )),\n                }?;\n                Ok(Avif { quality: q, speed: s })\n            }\n            _ => Err(anyhow!(\"Invalid image format: {}\", format)),\n        }\n    }\n\n    pub fn extension(&self) -> &str {\n        // Kept in sync with RESIZED_FILENAME and op_filename\n        use Format::*;\n\n        match *self {\n            Png => \"png\",","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/imageproc/src/format.rs#L55-L91","documentation":"Alongside quality, AVIF accepts a `--speed` flag controlling the encoder speed preset. `ImageFormat::from_args` validates it against the inclusive range SPEED_MIN_AVIF..=SPEED_MAX_AVIF; values outside raise this error with the bounds and the offending value.","triggerScenarios":"Running `zola image --format avif --speed <n>` where n is outside the AVIF speed bounds (commonly 0/1..10 depending on the constants; e.g. `--speed 20`).","commonSituations":"Confusing rav1e speed presets (0-10) with other encoders' effort levels; typo or doubled digit; copying `--speed` values from ffmpeg's libaom settings that use a different scale.","solutions":["Use a speed integer within SPEED_MIN_AVIF..=SPEED_MAX_AVIF (see components/imageproc/src/format.rs), typically 1-10","Omit `--speed` to use DEFAULT_SPEED_AVIF","If you wanted to control file size, adjust `--quality` instead of `--speed`"],"exampleFix":"// before\n$ zola image --format avif --speed 20 in.png out.avif\n// after\n$ zola image --format avif --speed 6 in.png out.avif","handlingStrategy":"validation","validationCode":"let s = speed.unwrap_or(DEFAULT_SPEED_AVIF);\nif !(SPEED_MIN_AVIF..=SPEED_MAX_AVIF).contains(&s) {\n    return Err(format!(\"AVIF speed must be {}-{}, got {}\", SPEED_MIN_AVIF, SPEED_MAX_AVIF, s));\n}","typeGuard":"fn is_valid_avif_speed(s: i32) -> bool {\n    (SPEED_MIN_AVIF..=SPEED_MAX_AVIF).contains(&s)\n}","tryCatchPattern":"match ImageFormat::from_args(\"avif\", quality, speed) {\n    Ok(f) => f,\n    Err(e) if e.to_string().contains(\"Speed for AVIF\") => {\n        eprintln!(\"Falling back to default AVIF speed\");\n        ImageFormat::from_args(\"avif\", quality, None)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check SPEED_MIN_AVIF/SPEED_MAX_AVIF constants for the accepted preset range","Omit --speed to use the default preset","Treat speed as an encode-time knob, not a quality knob — use --quality for file size"],"tags":["cli","images","validation","avif"],"backgroundTag":"invalid-quality-value","analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}