gohugoio/hugo · error
webp: animated image has no frames
Error message
webp: animated image has no frames
What it means
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.
Source
Thrown at internal/warpc/webp.go:273
var (
bounds = img.Bounds()
imageBytes []byte
stride int
frameDurations []int
loopCount int
command string
)
switch v := img.(type) {
case *image.RGBA:
imageBytes = v.Pix
stride = v.Stride
command = commandEncodeNRGBA
case *AnimatedImage:
// Animated WebP.
frames := v.GetFrames()
if len(frames) == 0 {
return errors.New("webp: animated image has no frames")
}
firstFrame := frames[0]
bounds = firstFrame.Bounds()
nrgba := convertToNRGBA(firstFrame)
frameSize := nrgba.Stride * bounds.Dy()
imageBytes = make([]byte, frameSize*len(frames))
stride = nrgba.Stride
for i, frame := range frames {
var nrgbaFrame *image.NRGBA
if i == 0 {
nrgbaFrame = nrgba
} else {
nrgbaFrame = convertToNRGBA(frame)
}
copy(imageBytes[i*frameSize:(i+1)*frameSize], nrgbaFrame.Pix)
}
frameDurations = v.GetFrameDurations()
loopCount = v.loopCountView on GitHub ↗ (pinned to 8a468df065)
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.
Defensive patterns
Strategy: validation
Validate before calling
if animated && frameCount == 0 {
return fmt.Errorf("animated source %s has no frames", path)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- webp: image is too large to encode
- decoded AVIF buffer size %d is not a multiple of frame size
- webp codec is not available
- gif: number of frame durations does not match number of fram
- format %q not supported
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/a83a236f57b62ea3.json.
Report an issue: GitHub ↗.