diff --git a/src/ImageSharp/Formats/WebP/LosslessUtils.cs b/src/ImageSharp/Formats/WebP/LosslessUtils.cs index a0b11121d3..600338e8ea 100644 --- a/src/ImageSharp/Formats/WebP/LosslessUtils.cs +++ b/src/ImageSharp/Formats/WebP/LosslessUtils.cs @@ -164,9 +164,10 @@ namespace SixLabors.ImageSharp.Formats.WebP } /// + /// This will reverse the predictor transform. /// The predictor transform can be used to reduce entropy by exploiting the fact that neighboring pixels are often correlated. /// In the predictor transform, the current pixel value is predicted from the pixels already decoded (in scan-line order) and only the residual value (actual - predicted) is encoded. - /// The prediction mode determines the type of prediction to use. We divide the image into squares and all the pixels in a square use same prediction mode. + /// The prediction mode determines the type of prediction to use. The image is divided into squares and all the pixels in a square use same prediction mode. /// /// The transform data. /// The pixel data to apply the inverse transform. diff --git a/src/ImageSharp/Formats/WebP/WebPLosslessDecoder.cs b/src/ImageSharp/Formats/WebP/WebPLosslessDecoder.cs index 64bbf5cc18..d4c1e7569f 100644 --- a/src/ImageSharp/Formats/WebP/WebPLosslessDecoder.cs +++ b/src/ImageSharp/Formats/WebP/WebPLosslessDecoder.cs @@ -617,6 +617,13 @@ namespace SixLabors.ImageSharp.Formats.WebP { var transformType = (Vp8LTransformType)this.bitReader.ReadBits(2); var transform = new Vp8LTransform(transformType, xSize, ySize); + + // Each transform is allowed to be used only once. + if (decoder.Transforms.Any(t => t.TransformType == transform.TransformType)) + { + WebPThrowHelper.ThrowImageFormatException("Each transform can only be present once"); + } + switch (transformType) { case Vp8LTransformType.SubtractGreen: