{"id":"bacc5e05d815c6b3","repo":"gohugoio/hugo","slug":"imaging-quality-must-be-between-1-and-100-inclusiv","errorCode":null,"errorMessage":"imaging.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":577,"sourceCode":"}\n\nfunc (cfg *ImagingConfig) init() error {\n\tcfg.BgColor = strings.ToLower(strings.TrimPrefix(cfg.BgColor, \"#\"))\n\tcfg.Anchor = strings.ToLower(cfg.Anchor)\n\tcfg.ResampleFilter = strings.ToLower(cfg.ResampleFilter)\n\tcfg.Hint = strings.ToLower(cfg.Hint)\n\tcfg.Compression = strings.ToLower(cfg.Compression)\n\tif err := cfg.Jpeg.init(cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid jpeg config: %w\", err)\n\t}\n\tif err := cfg.Webp.init(cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid webp config: %w\", err)\n\t}\n\tif err := cfg.Avif.init(cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid avif config: %w\", err)\n\t}\n\tif cfg.Quality < 0 || cfg.Quality > 100 {\n\t\treturn fmt.Errorf(\"imaging.quality must be between 1 and 100 inclusive, got %d\", cfg.Quality)\n\t}\n\n\tif cfg.Anchor == \"\" {\n\t\tcfg.Anchor = smartCropIdentifier\n\t}\n\n\tif strings.TrimSpace(cfg.Exif.IncludeFields) == \"\" && strings.TrimSpace(cfg.Exif.ExcludeFields) == \"\" {\n\t\t// Don't change this for no good reason. Please don't.\n\t\tcfg.Exif.ExcludeFields = \"GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance\"\n\t}\n\n\tif len(cfg.Meta.Fields) == 0 {\n\t\t// Default: include all fields except technical metadata.\n\t\t// Don't change this for no good reason. Please don't.\n\t\tcfg.Meta.Fields = []string{\n\t\t\t\"! *{GPS,Exif,Exposure[MPB],Contrast,Resolution,Sharp,JPEG,Metering,Sensing,Saturation,ColorSpace,Flash,WhiteBalance}*\",\n\t\t}\n\t}","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L559-L595","documentation":"During site-config initialization, ImagingConfig.init validates the global imaging.quality setting. Values outside 0–100 fail (0 is allowed here as 'unset' and later defaulted per-format), because encoders require quality in 1–100.","triggerScenarios":"Setting imaging.quality = 150, -1, or any value > 100 or < 0 in hugo.toml/config.toml (or the params equivalent) — the error fires at config load, before any image is processed.","commonSituations":"Confusing quality percentages with other scales (e.g. entering 0–1 floats multiplied wrong, or 0–255); typos like 750 for 75; copying config from tools with different quality ranges.","solutions":["Set imaging.quality in hugo.toml to a value between 1 and 100 (Hugo's default is 75).","Remove the setting entirely to use the default.","If different formats need different quality, use imaging.jpeg.quality / per-call q options instead of an out-of-range global."],"exampleFix":"# before (hugo.toml)\n[imaging]\nquality = 150\n# after\n[imaging]\nquality = 75","handlingStrategy":"validation","validationCode":"q := cfg.Imaging.Quality\nif q < 1 || q > 100 {\n    return fmt.Errorf(\"imaging.quality must be 1-100, got %d\", q)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate site config (hugo.toml [imaging] quality) before deploys, e.g. in CI with a dry-run build","Remember quality defaults to 75; only set it when needed and keep it in 1–100","Treat config validation failures as fail-fast build errors, not warnings"],"tags":["hugo","config","image-processing","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}