{"record":{"id":"80cbda44381c0728","repo":"getzola/zola","slug":"quality-for-jpeg-must-be-between-and-inclus","errorCode":null,"errorMessage":"Quality for JPEG must be between {} and {} (inclusive); {} is not valid","messagePattern":"Quality for JPEG must be between (.+?) and (.+?) \\(inclusive\\); (.+?) is not valid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/imageproc/src/format.rs","lineNumber":44,"sourceCode":"impl Format {\n    pub fn from_args(\n        is_lossy: bool,\n        format: &str,\n        quality: Option<u8>,\n        speed: Option<u8>,\n    ) -> Result<Format> {\n        use Format::*;\n        let format_from_auto = match (format, is_lossy) {\n            (\"auto\", true) => \"jpeg\",\n            (\"auto\", false) => \"png\",\n            (other_format, _) => other_format,\n        };\n        match format_from_auto {\n            \"jpeg\" | \"jpg\" => match quality.unwrap_or(DEFAULT_QUALITY_JPEG) {\n                valid_quality @ QUALITY_MIN_JPEG..=QUALITY_MAX_JPEG => {\n                    Ok(Jpeg { quality: valid_quality })\n                }\n                invalid_quality => Err(anyhow!(\n                    \"Quality for JPEG must be between {} and {} (inclusive); {} is not valid\",\n                    QUALITY_MIN_JPEG,\n                    QUALITY_MAX_JPEG,\n                    invalid_quality\n                )),\n            },\n            \"png\" => Ok(Png),\n            \"webp\" => match quality {\n                Some(QUALITY_MIN_WEBP..=QUALITY_MAX_WEBP) | None => Ok(WebP { quality }),\n                Some(invalid_quality) => Err(anyhow!(\n                    \"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) {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/imageproc/src/format.rs#L26-L62","documentation":"`ImageFormat::from_args` validates the `--quality` argument when the output format is JPEG. JPEG quality must be an integer within the inclusive range QUALITY_MIN_JPEG..=QUALITY_MAX_JPEG (1..=100); anything outside raises this error naming the valid bounds and the offending value.","triggerScenarios":"Running `zola image --quality <n> --format jpeg|jpg` (or equivalent imageproc API) where n < 1 or n > 100 (or otherwise outside the JPEG bounds, e.g. 0 or 150).","commonSituations":"Using a 0.0-1.0 float quality convention (e.g. 0.8) from other tools; typos like 500; reusing WebP/AVIF decimal quality values; forgetting that quality must be an integer here.","solutions":["Pass an integer quality between 1 and 100, e.g. `--quality 80`","Remove the `--quality` flag to use the built-in JPEG default (DEFAULT_QUALITY_JPEG)","Convert fractional quality (0-1) to percent (multiply by 100 and round)"],"exampleFix":"// before\n$ zola image --format jpg --quality 0.8 in.png out.jpg\n// after\n$ zola image --format jpg --quality 80 in.png out.jpg","handlingStrategy":"validation","validationCode":"if let Some(q) = quality {\n    if !(1..=100).contains(&q) {\n        return Err(format!(\"JPEG quality must be 1-100, got {}\", q));\n    }\n}","typeGuard":"fn is_valid_jpeg_quality(q: u8) -> bool { (1..=100).contains(&q) }","tryCatchPattern":"match ImageFormat::from_args(format, quality, speed) {\n    Ok(f) => f,\n    Err(e) if e.to_string().contains(\"Quality for JPEG\") => {\n        eprintln!(\"Use an integer 1-100 for JPEG quality\");\n        ImageFormat::Jpeg { quality: 75 }\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always use integer 0-100 scale quality, never 0.0-1.0 floats","Omit the quality flag when unsure; built-in defaults are safe","Clamp user input (q.clamp(1, 100)) before passing to from_args"],"tags":["cli","images","validation","jpeg"],"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"}