@ -58,7 +58,7 @@ internal sealed unsafe partial class JpegEncoderCore
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
if (image.Width >= JpegConstants.MaxLength || image.Height >= JpegConstants.MaxLength)
if (image.Width > JpegConstants.MaxLength || image.Height > JpegConstants.MaxLength)
{
JpegThrowHelper.ThrowDimensionsTooLarge(image.Width, image.Height);
}
@ -371,9 +371,6 @@ internal class Vp8LEncoder : IDisposable
/// <param name="inputImgHeight">The input image height.</param>
private void WriteImageSize(int inputImgWidth, int inputImgHeight)
Guard.MustBeLessThan(inputImgWidth, WebpConstants.MaxDimension, nameof(inputImgWidth));
Guard.MustBeLessThan(inputImgHeight, WebpConstants.MaxDimension, nameof(inputImgHeight));
uint width = (uint)inputImgWidth - 1;
uint height = (uint)inputImgHeight - 1;
@ -132,6 +132,11 @@ internal sealed class WebpEncoderCore
if (image.Width > WebpConstants.MaxDimension || image.Height > WebpConstants.MaxDimension)
WebpThrowHelper.ThrowDimensionsTooLarge(image.Width, image.Height);
bool lossless;
if (this.fileFormat is not null)
@ -18,4 +18,7 @@ internal static class WebpThrowHelper
[DoesNotReturn]
public static void ThrowInvalidImageDimensions(string errorMessage) => throw new InvalidImageContentException(errorMessage);
public static void ThrowDimensionsTooLarge(int width, int height) => throw new ImageFormatException($"Image is too large to encode at {width}x{height} for WEBP format.");