{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L647-L683","documentation":"JpegConfig.init resolves the effective JPEG quality: explicit imaging.jpeg.quality, else the global imaging.quality, else 75. The resolved value must be 1–100 for the JPEG encoder; anything else is rejected at config load.","triggerScenarios":"Setting imaging.jpeg.quality outside 1–100 in site config, or a negative global imaging.quality inherited into the JPEG config (note: 0 means unset and falls through to defaults, so 0 itself doesn't trigger this).","commonSituations":"Typos (e.g. 850 for 85); assuming a 0–1 float scale; setting a negative value to mean 'disable'; copy-pasting config across tools with different ranges.","solutions":["Set imaging.jpeg.quality in hugo.toml to a value between 1 and 100.","Remove the setting to inherit imaging.quality or the default of 75.","If you meant to control quality per-call, use the qN option in the template instead."],"exampleFix":"# before (hugo.toml)\n[imaging.jpeg]\nquality = 850\n# after\n[imaging.jpeg]\nquality = 85","handlingStrategy":"validation","validationCode":"if q := cfg.Imaging.JPEG.Quality; q != 0 && (q < 1 || q > 100) {\n    return fmt.Errorf(\"imaging.jpeg.quality must be 1-100, got %d\", q)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate format-specific quality overrides ([imaging.jpeg]) with the same 1–100 rule as the global quality","Run a CI hugo build against config changes so bad values fail before merge","Document the valid range next to the config key in your repo's config comments"],"tags":["hugo","config","jpeg","image-processing","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}