{"record":{"id":"25cb55469cfeb04b","repo":"gohugoio/hugo","slug":"failed-to-s-image-q-w","errorCode":null,"errorMessage":"failed to %s image %q: %w","messagePattern":"failed to (.+?) image %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/image.go","lineNumber":363,"sourceCode":"\t\t\t\t\torientation = meta.Orientation\n\t\t\t\t}\n\t\t\t\tif tf := orientationProvider.AutoOrient(orientation); tf != nil {\n\t\t\t\t\tfilters = append(filters, tf)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilters = append(filters, f)\n\t\t\t}\n\t\t}\n\t\treturn i.Proc.Filter(src, filters...)\n\t})\n}\n\nfunc (i *imageResource) processActionSpec(action, spec string) (images.ImageResource, error) {\n\toptions := append([]string{action}, strings.Fields(strings.ToLower(spec))...)\n\tir, err := i.processOptions(options)\n\tif err != nil {\n\t\tif sourcePath := i.sourcePath(); sourcePath != \"\" {\n\t\t\terr = fmt.Errorf(\"failed to %s image %q: %w\", action, sourcePath, err)\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn ir, nil\n}\n\nfunc (i *imageResource) processOptions(options []string) (images.ImageResource, error) {\n\tconf, err := images.DecodeImageConfig(options, i.Proc.Cfg, i.Format)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\timg, err := i.doWithImageConfig(conf, func(src image.Image) (image.Image, error) {\n\t\treturn i.Proc.ApplyFiltersFromConfig(src, conf)\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/image.go#L345-L381","documentation":"Returned by imageResource.processActionSpec when processing options for Resize/Crop/Fit/Fill/Process fails. It wraps the underlying error (from DecodeImageConfig or doWithImageConfig) and prepends the action verb and the source file path for diagnostics. This is the top-level error for any image transformation invoked via the spec-string API.","triggerScenarios":"Calling .Resize(\"300x\"), .Crop(\"200x200 Foo\"), .Fill(\"100x100 smart\") etc. where the spec string is malformed (unknown anchor, bad dimensions, invalid quality) or where the actual filter application fails (corrupt source image, unsupported format, out-of-memory).","commonSituations":"A typo in a spec string (e.g. \"300xTopleft\"), an unsupported resample filter name, a quality value out of range, a corrupted source image that decodes but fails to process, or smartcrop failing silently on degenerate images.","solutions":["Read the wrapped error -- it pinpoints whether DecodeImageConfig (spec parsing) or doWithImageConfig (actual processing) failed.","Fix the spec string: valid anchors (Center, TopLeft, smart), valid NxM dimensions, q1-100 quality.","If the source image is corrupt, replace it or exclude it from processing.","For smartcrop silent failures, note the code falls back to Center fill automatically (issue 7955)."],"exampleFix":"// before\n{{ $img := (.Resize \"300xTopleft\") }}\n\n// after: correct anchor spelling\n{{ $img := (.Resize \"300x TopLeft\") }}","handlingStrategy":"validation","validationCode":"// Validate spec string before calling Resize/Crop/Fill.\nvar validSpecAnchors = map[string]bool{\"center\": true, \"topleft\": true, \"top\": true, \"topright\": true, \"left\": true, \"right\": true, \"bottomleft\": true, \"bottom\": true, \"bottomright\": true, \"smart\": true}\nfunc checkSpec(spec string) error {\n    for _, tok := range strings.Fields(strings.ToLower(spec)) {\n        if strings.HasPrefix(tok, \"q\") { /* parse 1-100 */ }\n        if strings.HasPrefix(tok, \"#\") { /* valid hex */ }\n        if strings.Contains(tok, \"x\") { /* NxM */ }\n        if !validSpecAnchors[tok] && !validFilters[tok] { /* unknown token */ }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := img.Resize(spec); err != nil {\n    var pe *os.PathError\n    if errors.As(err, &pe) { /* decode/processing failure on the file */ }\n    return err\n}","preventionTips":["Double-check anchor/filter spelling in spec strings.","Keep quality in 1-100 and dimensions as positive integers.","Test image-processing templates against a known-good sample image."],"tags":["image-processing","resize","spec-string","transform"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}