{"id":"1a9ef17791717180","repo":"gohugoio/hugo","slug":"imaging-webp-quality-must-be-between-1-and-100-inc","errorCode":null,"errorMessage":"imaging.webp.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.webp\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":791,"sourceCode":"\t}\n\tif c.Quality == 0 {\n\t\tc.Quality = 75\n\t}\n\n\tc.Hint = strings.ToLower(c.Hint)\n\tc.Compression = strings.ToLower(c.Compression)\n\n\tif c.Hint != \"\" && !hints[c.Hint] {\n\t\treturn fmt.Errorf(\"imaging.webp.hint must be one of picture, photo, drawing, icon, or text, got %q\", c.Hint)\n\t}\n\tif c.Method < 0 || c.Method > 6 {\n\t\treturn fmt.Errorf(\"imaging.webp.method must be between 0 and 6, got %d\", c.Method)\n\t}\n\tif c.Compression != \"\" && !compressionMethods[c.Compression] {\n\t\treturn fmt.Errorf(\"imaging.webp.compression must be one of lossy or lossless, got %q\", c.Compression)\n\t}\n\tif c.Quality < 1 || c.Quality > 100 {\n\t\treturn fmt.Errorf(\"imaging.webp.quality must be between 1 and 100 inclusive, got %d\", c.Quality)\n\t}\n\treturn nil\n}\n","sourceCodeStart":773,"sourceCodeEnd":795,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L773-L795","documentation":"WebpConfig.init validates the effective WebP quality: an unset (0) value falls back to the global `imaging.quality` and then to 75, so a value that fails the 1-100 check was explicitly set out of range. Quality only affects lossy encoding.","triggerScenarios":"Configuring `[imaging.webp] quality` (or the inherited global `[imaging] quality`) with a negative value or one above 100.","commonSituations":"Using 0.0-1.0 fractional scales from JS image libraries, adding an extra digit (750), or setting -1 hoping for \"auto\" quality.","solutions":["Set `imaging.webp.quality` to an integer between 1 and 100 (default 75).","For maximum fidelity use `compression = \"lossless\"` rather than quality > 100.","Remove the key to inherit the global quality or default."],"exampleFix":"# before\n[imaging.webp]\nquality = 0.8\n# after\n[imaging.webp]\nquality = 80","handlingStrategy":"validation","validationCode":"if q := cfg.Imaging.WebP.Quality; q < 1 || q > 100 {\n    return fmt.Errorf(\"webp quality %d out of range [1,100]\", q)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep quality in 1–100; 0 is rejected, not treated as default","Validate per-image processing specs (e.g. `.Resize \"600x webp q85\"`) with the same range","Cover imaging config with a smoke build in CI"],"tags":["hugo","config","imaging","webp"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}