{"record":{"id":"b9d4bc3d379a984c","repo":"gohugoio/hugo","slug":"t-is-not-an-image-filter","errorCode":null,"errorMessage":"%T is not an image filter","messagePattern":"%T is not an image filter","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/image.go","lineNumber":505,"sourceCode":"\t}\n\treturn in\n}\n\n// ToFilters converts the given input to a slice of gift.Filter.\nfunc ToFilters(in any) []gift.Filter {\n\tswitch v := in.(type) {\n\tcase []gift.Filter:\n\t\treturn v\n\tcase []filter:\n\t\tvv := make([]gift.Filter, len(v))\n\t\tfor i, f := range v {\n\t\t\tvv[i] = f\n\t\t}\n\t\treturn vv\n\tcase gift.Filter:\n\t\treturn []gift.Filter{v}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"%T is not an image filter\", in))\n\t}\n}\n\n// IsOpaque returns false if the image has alpha channel and there is at least 1\n// pixel that is not (fully) opaque.\nfunc IsOpaque(img image.Image) bool {\n\tif oim, ok := img.(interface {\n\t\tOpaque() bool\n\t}); ok {\n\t\treturn oim.Opaque()\n\t}\n\n\treturn false\n}\n\n// ImageSource identifies and decodes an image.\ntype ImageSource interface {\n\tDecodeImage() (image.Image, error)","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/image.go#L487-L523","documentation":"Thrown by images.ToFilters when the input is not a filter, a slice of filters, or a single filter wrapper (image.go:492-506). ToFilters is used internally by image processing pipelines to normalize a heterogeneous argument list into []gift.Filter; unrecognized types panic with the concrete Go type (%T).","triggerScenarios":"Passing a non-filter value (string, int, map, arbitrary struct) where a filter is expected — typically via the images.Process filter list or when manually building a filter slice with mixed types.","commonSituations":"Template builds a filter slice and accidentally appends a plain value (e.g. a color string or a resource) instead of a filter produced by images.* functions.","solutions":["Ensure every element is produced by an images.* filter constructor (Process, Text, Padding, Dither, etc.).","Do not append raw scalars, resources, or maps to a filter slice.","Inspect the printed type (%T) to find the offending element."],"exampleFix":"// before\n{{ $filters := slice }}\n{{ $filters = $filters | append \"#ffffff\" }}\n{{ $img := $img.Filter $filters }}\n// after\n{{ $filters := slice }}\n{{ $filters = $filters | append (images.Padding 10 \"#ffffff\") }}\n{{ $img := $img.Filter $filters }}","handlingStrategy":"type-guard","validationCode":"{{ range $f := $filters }}\n  {{ if not (reflect.IsMap $f) }}{{ end }}\n{{ end }}","typeGuard":"// IsGiftFilter reports whether v can be accepted by images.ToFilters.\nfunc IsGiftFilter(v any) bool {\n    switch v.(type) {\n    case gift.Filter, []gift.Filter, images.FilterWrapper:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Only append results of images.* filter constructors to filter slices.","Avoid mixing scalar/resource values into a filter list.","Inspect the %T in the error to locate the bad element."],"tags":["image-filter","type-mismatch","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}