{"record":{"id":"8e937ad1d71f2e5f","repo":"gohugoio/hugo","slug":"webp-image-is-too-large-to-encode","errorCode":null,"errorMessage":"webp: image is too large to encode","messagePattern":"webp: image is too large to encode","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/warpc/webp.go","lineNumber":242,"sourceCode":"\t\t\tSource: bytes.NewReader(b),\n\t\t},\n\t}\n\n\tout, err := dd.Execute(context.Background(), message)\n\tif err != nil {\n\t\treturn image.Config{}, err\n\t}\n\treturn image.Config{\n\t\tWidth:      out.Data.Params.Width,\n\t\tHeight:     out.Data.Params.Height,\n\t\tColorModel: color.RGBAModel,\n\t}, nil\n}\n\nfunc (d *WebpCodec) Encode(w io.Writer, img image.Image, opts map[string]any) error {\n\tb := img.Bounds()\n\tif b.Dx() >= 1<<16 || b.Dy() >= 1<<16 {\n\t\treturn errors.New(\"webp: image is too large to encode\")\n\t}\n\n\tdd, err := d.d()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconst (\n\t\tcommandEncodeNRGBA = \"encodeNRGBA\"\n\t\tcommandEncodeGray  = \"encodeGray\"\n\t)\n\n\tvar (\n\t\tbounds         = img.Bounds()\n\t\timageBytes     []byte\n\t\tstride         int\n\t\tframeDurations []int\n\t\tloopCount      int","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/warpc/webp.go#L224-L260","documentation":"Returned by WebpCodec.Encode in internal/warpc/webp.go:242 when either image dimension (Dx or Dy of the bounds) is >= 65536 (1<<16). WebP's format limit is 16383 per axis in libwebp and the codec rejects anything at/above 2^16 outright before dispatching to WASM.","triggerScenarios":"Calling webp encode (|webp or resources with webp output) on an image whose width or height is 65536 pixels or more. The check runs locally before any WASM call.","commonSituations":"A huge hero/panorama image, an accidentally upsampled image, or a stitched sprite atlas exceeding the dimension cap.","solutions":["Resize/downsample the image so both dimensions stay well under 65536 (preferably <= 16383, libwebp's practical max).","Switch the output format to JPEG/PNG for ultra-large images that legitimately need huge dimensions.","Check the source pipeline for an accidental upscale (e.g. a \"Resize 99999x\" typo)."],"exampleFix":"// before\n{{ $webp = $hugeImg.Resize \"70000x webp\" }}\n// after\n{{ $webp = $hugeImg.Resize \"1600x webp\" }}","handlingStrategy":"validation","validationCode":"// Reject oversized images before webp encode.\nb := img.Bounds()\nif b.Dx() >= 1<<16 || b.Dy() >= 1<<16 {\n    return fmt.Errorf(\"image %dx%d too large for webp\", b.Dx(), b.Dy())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap source dimensions early in the pipeline.","Prefer JPEG/PNG for legitimately huge images.","Audit Resize calls for accidental upscales."],"tags":["webp","image","limits"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}