{"record":{"id":"45cc5e281186e373","repo":"gohugoio/hugo","slug":"imaging-avif-quality-must-be-between-1-and-100-inc","errorCode":null,"errorMessage":"imaging.avif.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.avif\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":728,"sourceCode":"\tif c.Quality == 0 {\n\t\tc.Quality = 60\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.avif.hint must be one of picture, photo, drawing, icon, or text, got %q\", c.Hint)\n\t}\n\tif c.EncoderSpeed < 1 || c.EncoderSpeed > 10 {\n\t\treturn fmt.Errorf(\"imaging.avif.encoderSpeed must be between 1 and 10, got %d\", c.EncoderSpeed)\n\t}\n\n\tif c.Compression != \"\" && !compressionMethods[c.Compression] {\n\t\treturn fmt.Errorf(\"imaging.avif.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.avif.quality must be between 1 and 100 inclusive, got %d\", c.Quality)\n\t}\n\n\treturn nil\n}\n\n// WebpConfig holds WebP-specific encoding configuration.\ntype WebpConfig struct {\n\t// Quality setting (1-100). Falls back to the global imaging.quality if unset.\n\t// Only relevant for lossy encoding.\n\tQuality int\n\n\t// Compression method to use.\n\t// One of \"lossy\" or \"lossless\".\n\tCompression string\n\n\t// Hint about what type of image this is.\n\t// Valid values are \"picture\", \"photo\", \"drawing\", \"icon\", or \"text\".\n\t// Default is \"photo\".","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L710-L746","documentation":"Validates the AVIF quality after fallback resolution. If imaging.avif.quality is 0, it inherits the global imaging.quality; if that is also 0, it defaults to 60 (lower than JPEG/WebP because AVIF is more efficient). After resolution, quality must be between 1 and 100 inclusive.","triggerScenarios":"Setting [imaging.avif] quality in hugo.toml to a value below 1 or above 100. A value of 0 does not trigger this — it triggers the fallback to global quality or the default 60.","commonSituations":"Setting AVIF quality to the same value as JPEG quality (AVIF needs lower values for equivalent visual quality); setting quality above 100; setting it to 0 expecting lossless (use compression = 'lossless' instead).","solutions":["Set imaging.avif.quality to a value between 1 and 100. AVIF typically looks good at 40-70.","If you want lossless AVIF, set compression = 'lossless' instead of cranking quality to 100.","Omit the quality key to use the default 60, which is a good starting point for web photographs."],"exampleFix":"# before (hugo.toml)\n[imaging.avif]\nquality = 100\ncompression = \"lossy\"\n\n# after\n[imaging.avif]\nquality = 55\ncompression = \"lossy\"","handlingStrategy":"validation","validationCode":"// Validate AVIF quality (0 = inherit global or default 60)\nfunc validateAvifQuality(q, globalQuality int) error {\n    resolved := q\n    if resolved == 0 { resolved = globalQuality }\n    if resolved == 0 { resolved = 60 }\n    if resolved < 1 || resolved > 100 {\n        return fmt.Errorf(\"avif quality resolves to %d, out of range [1,100]\", resolved)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["AVIF default quality is 60, lower than JPEG/WebP 75 — do not match them blindly.","For lossless AVIF, set compression='lossless' rather than quality=100.","Test AVIF quality in increments of 5-10; the visual quality curve is steep."],"tags":["hugo","imaging","avif","config-validation","quality"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}