{"record":{"id":"d22d66ca25e35c00","repo":"SixLabors/ImageSharp","slug":"image-is-too-large-to-encode-at-width-x-height-for-webp","errorCode":null,"errorMessage":"Image is too large to encode at {width}x{height} for WEBP format.","messagePattern":"Image is too large to encode at (.+?)x(.+?) for WEBP format\\.","errorType":"exception","errorClass":"ImageFormatException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Webp/WebpThrowHelper.cs","lineNumber":23,"sourceCode":"\nnamespace SixLabors.ImageSharp.Formats.Webp;\n\ninternal static class WebpThrowHelper\n{\n    [DoesNotReturn]\n    public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);\n\n    [DoesNotReturn]\n    public static void ThrowImageFormatException(string errorMessage) => throw new ImageFormatException(errorMessage);\n\n    [DoesNotReturn]\n    public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage);\n\n    [DoesNotReturn]\n    public static void ThrowInvalidImageDimensions(string errorMessage) => throw new InvalidImageContentException(errorMessage);\n\n    [DoesNotReturn]\n    public static void ThrowDimensionsTooLarge(int width, int height) => throw new ImageFormatException($\"Image is too large to encode at {width}x{height} for WEBP format.\");\n}\n","sourceCodeStart":5,"sourceCodeEnd":25,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Webp/WebpThrowHelper.cs#L5-L25","documentation":"WebpThrowHelper.ThrowDimensionsTooLarge throws ImageFormatException when encoding a WebP image whose width or height exceeds the WebP format limit (16383x16383, since VP8L/VP8X dimension fields are 14 bits). The message reports the offending width x height. The decoder cannot represent larger images in WebP.","triggerScenarios":"Calling SaveAsWebp (or the WebpEncoder) on an image larger than 16383 pixels in either dimension; also hit when downscaled animation frames still exceed the limit.","commonSituations":"Encoding stitched panoramas, high-res scans, or large satellite/medical imagery directly to WebP; pipelines that crop after encoding rather than before.","solutions":["Resize the image to <= 16383x16383 before encoding (image.Mutate(x => x.Resize(...))).","Tile the image into multiple WebP files each within the limit.","Choose a different format without this limit (PNG, JPEG, TIFF) for oversized images.","Add a pre-flight check using image.Width/image.Height against the limit and fail fast with a clear message."],"exampleFix":"// before\nimage.SaveAsWebp(\"huge.webp\"); // throws if > 16383px\n// after\nif (image.Width > 16383 || image.Height > 16383)\n{\n    image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2));\n}\nimage.SaveAsWebp(\"huge.webp\");","handlingStrategy":"validation","validationCode":"if (image.Width > 16383 || image.Height > 16383)\n    image.Mutate(x => x.Resize(new ResizeOptions { Mode = ResizeMode.Max, Size = new(16383, 16383) }));","typeGuard":"static bool FitsWebpLimits(int width, int height) => (uint)width <= 16383u && (uint)height <= 16383u;","tryCatchPattern":"try { image.SaveAsWebp(path); }\ncatch (ImageFormatException ex) when (ex.Message.Contains(\"too large\")) { /* resize and retry */ }","preventionTips":["Pre-check dimensions against 16383 before every WebP encode","Tile or downsize large imagery in the pipeline","Pick another format for oversized assets"],"tags":["webp","encoder","dimensions","limit"],"backgroundTag":"payload-too-large","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}