{"record":{"id":"b3d1ef3fa4354852","repo":"gohugoio/hugo","slug":"imaging-jpeg-quality-must-be-between-1-and-100-inc","errorCode":null,"errorMessage":"imaging.jpeg.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.jpeg\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":665,"sourceCode":"\t// Default is [\"exif\", \"iptc\"] (XMP is excluded for performance reasons).\n\tSources []string\n}\n\n// JpegConfig holds JPEG-specific encoding configuration.\ntype JpegConfig struct {\n\t// Quality setting (1-100). Falls back to the global imaging.quality if unset.\n\tQuality int\n}\n\nfunc (c *JpegConfig) init(ic *ImagingConfig) error {\n\tif c.Quality == 0 {\n\t\tc.Quality = ic.Quality\n\t}\n\tif c.Quality == 0 {\n\t\tc.Quality = 75\n\t}\n\tif c.Quality < 1 || c.Quality > 100 {\n\t\treturn fmt.Errorf(\"imaging.jpeg.quality must be between 1 and 100 inclusive, got %d\", c.Quality)\n\t}\n\treturn nil\n}\n\n// AvifConfig holds AVIF-specific encoding configuration.\ntype AvifConfig struct {\n\t// Quality setting (1-100). Falls back to the global imaging.quality if unset.\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. Used for chroma subsampling.\n\t// Valid values are \"picture\", \"photo\", \"drawing\", \"icon\", or \"text\".\n\t// Default is \"photo\".\n\tHint string\n","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L647-L683","documentation":"Validates the JPEG-specific quality after fallback resolution. If imaging.jpeg.quality is 0, it inherits the global imaging.quality; if that is also 0, it defaults to 75. After resolution, quality must be between 1 and 100 inclusive. This check runs inside JpegConfig.init, which is called from ImagingConfig.init.","triggerScenarios":"Setting [imaging.jpeg] quality in hugo.toml to a value below 1 or above 100. Note: a quality of 0 does NOT trigger this error — it triggers the fallback chain to the global quality or default 75.","commonSituations":"Setting JPEG quality to 0 expecting lossless encoding (JPEG does not support lossless in Hugo); setting quality above 100; an off-by-one from a config migration.","solutions":["Set imaging.jpeg.quality to a value between 1 and 100 in hugo.toml (typical web values: 70-85).","If you want the default (75), simply omit the quality key under [imaging.jpeg].","If you set it to 0 intentionally to inherit the global quality, make sure the global imaging.quality is itself valid (1-100)."],"exampleFix":"# before (hugo.toml)\n[imaging.jpeg]\nquality = 0\n\n[imaging]\nquality = 0\n# jpeg quality resolves to default 75 — fine, but if you explicitly want control:\n\n# after\n[imaging.jpeg]\nquality = 82","handlingStrategy":"validation","validationCode":"// Validate JPEG quality (0 = inherit global or default 75)\nfunc validateJpegQuality(q, globalQuality int) error {\n    resolved := q\n    if resolved == 0 { resolved = globalQuality }\n    if resolved == 0 { resolved = 75 }\n    if resolved < 1 || resolved > 100 {\n        return fmt.Errorf(\"jpeg quality resolves to %d, out of range [1,100]\", resolved)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit imaging.jpeg.quality to inherit the global imaging.quality or default 75.","For web JPEGs, 70-85 is the sweet spot; above 90 yields minimal visible improvement with large files.","JPEG does not support lossless in Hugo — use WebP or AVIF with compression='lossless' instead."],"tags":["hugo","imaging","jpeg","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"}