{"id":"a83a236f57b62ea3","repo":"gohugoio/hugo","slug":"webp-animated-image-has-no-frames","errorCode":null,"errorMessage":"webp: animated image has no frames","messagePattern":"webp: animated image has no frames","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/warpc/webp.go","lineNumber":273,"sourceCode":"\tvar (\n\t\tbounds         = img.Bounds()\n\t\timageBytes     []byte\n\t\tstride         int\n\t\tframeDurations []int\n\t\tloopCount      int\n\t\tcommand        string\n\t)\n\n\tswitch v := img.(type) {\n\tcase *image.RGBA:\n\t\timageBytes = v.Pix\n\t\tstride = v.Stride\n\t\tcommand = commandEncodeNRGBA\n\tcase *AnimatedImage:\n\t\t// Animated WebP.\n\t\tframes := v.GetFrames()\n\t\tif len(frames) == 0 {\n\t\t\treturn errors.New(\"webp: animated image has no frames\")\n\t\t}\n\t\tfirstFrame := frames[0]\n\t\tbounds = firstFrame.Bounds()\n\t\tnrgba := convertToNRGBA(firstFrame)\n\t\tframeSize := nrgba.Stride * bounds.Dy()\n\t\timageBytes = make([]byte, frameSize*len(frames))\n\t\tstride = nrgba.Stride\n\t\tfor i, frame := range frames {\n\t\t\tvar nrgbaFrame *image.NRGBA\n\t\t\tif i == 0 {\n\t\t\t\tnrgbaFrame = nrgba\n\t\t\t} else {\n\t\t\t\tnrgbaFrame = convertToNRGBA(frame)\n\t\t\t}\n\t\t\tcopy(imageBytes[i*frameSize:(i+1)*frameSize], nrgbaFrame.Pix)\n\t\t}\n\t\tframeDurations = v.GetFrameDurations()\n\t\tloopCount = v.loopCount","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/internal/warpc/webp.go#L255-L291","documentation":"Returned by WebpCodec.Encode (internal/warpc/webp.go:273) when asked to encode an AnimatedImage whose GetFrames() returns an empty slice. An animated WebP needs at least one frame to build the pixel buffer and frame-duration list, so an empty animation is rejected as invalid input rather than silently producing an empty file.","triggerScenarios":"Converting an animated source (animated AVIF/GIF decoded into Hugo's AnimatedImage) to WebP when the decoded frame list is empty — typically a corrupt or zero-frame source animation, or an upstream decode that populated frame durations but no pixel frames.","commonSituations":"Corrupt or truncated animated GIF/AVIF assets fed through .Process \"webp\"; exotic animations from online converters that declare animation metadata with no actual frames; upstream decoder bugs after format edge cases.","solutions":["Validate the source animation (open it in a browser / ffprobe); re-export it from the original tool.","Re-encode the source with a standard tool (ffmpeg, gifsicle, avifenc) before adding it to the site.","If a browser-valid animation triggers this, report it to Hugo with the file — it points to a decode-side bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if animated && frameCount == 0 {\n    return fmt.Errorf(\"animated source %s has no frames\", path)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify animated GIF/WebP sources actually contain frames (a corrupt or zero-frame file is the trigger)","Validate downloaded/user-uploaded animations before adding them to assets","Surface the offending filename so the bad asset can be replaced"],"tags":["hugo","webp","animated-image","image-processing","encode"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}