-
-
Notifications
You must be signed in to change notification settings - Fork 888
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.1.12
Other ImageSharp packages and versions
3.1.11
Environment (Operating system, version and so on)
Windows 11 latest
.NET Framework version
dotnet 8
Description
My client have a animation webp file with invalid EXIF, probably exported from Adobe. It shows only as warning in webpinfo, but throw SixLabors.ImageSharp.ImageFormatException : Invalid Webp data, could not read chunk size when load the image.
Message:
System.AggregateException : One or more errors occurred. (Invalid Webp data, could not read chunk size.) (Expected 0 undisposed buffers but found 151)
---- SixLabors.ImageSharp.ImageFormatException : Invalid Webp data, could not read chunk size.
---- Expected 0 undisposed buffers but found 151
Stack Trace:
----- Inner Stack Trace #1 (SixLabors.ImageSharp.ImageFormatException) -----
WebpChunkParsingUtils.ReadChunkSize(Stream stream, Span1 buffer) line 307 WebpChunkParsingUtils.ParseOptionalChunks(BufferedReadStream stream, WebpChunkType chunkType, ImageMetadata metadata, Boolean ignoreMetaData, Span1 buffer) line 341
WebpAnimationDecoder.Decode[TPixel](BufferedReadStream stream, WebpFeatures features, UInt32 width, UInt32 height, UInt32 completeDataSize) line 131
WebpDecoderCore.Decode[TPixel](BufferedReadStream stream, CancellationToken cancellationToken) line 93
ImageDecoderCore.Decode[TPixel](Configuration configuration, Stream stream, CancellationToken cancellationToken) line 82
WebpDecoder.Decode[TPixel](WebpDecoderOptions options, Stream stream, CancellationToken cancellationToken) line 39
SpecializedImageDecoder1.Decode[TPixel](DecoderOptions options, Stream stream, CancellationToken cancellationToken) line 103 <>c__DisplayClass0_01.b__0(Stream s) line 24
ImageDecoder.g__PerformActionAndResetPosition|11_0[T](Stream s, Int64 position, <>c__DisplayClass11_01&) line 195 ImageDecoder.WithSeekableStream[T](DecoderOptions options, Stream stream, Func2 action) line 210
ImageDecoder.Decode[TPixel](DecoderOptions options, Stream stream) line 21
FileProvider.DecodeImage(IImageDecoder decoder, DecoderOptions options) line 275
FileProvider.GetImage(IImageDecoder decoder, DecoderOptions options) line 196
TestImageProvider1.GetImage(IImageDecoder decoder) line 91 WebpDecoderTests.WebpDecoder_CanDecode_WarningExif[TPixel](TestImageProvider1 provider) line 558
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
----- Inner Stack Trace #2 (Xunit.Sdk.TrueException) -----
TestMemoryDiagnostics.Validate(Int32 expectedAllocationCount) line 61
MemoryAllocatorValidator.ValidateAllocations(Int32 expectedAllocationCount) line 49
ValidateDisposedMemoryAllocationsAttribute.After(MethodInfo methodUnderTest) line 27
Steps to Reproduce
-
unzip the attached zip, and put into test file Webp/exif_warning.webp
-
define the following in TestImages.cs / class Webp
public const string WarningExif = "Webp/exif_warning.webp";
- Add following test in Formats\WebP\WebDecoderTests.cs:
[Theory]
[WithFile(WarningExif, PixelTypes.Rgba32)]
public void WebpDecoder_CanDecode_WarningExif<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(WebpDecoder.Instance);
image.DebugSave(provider);
image.CompareToOriginal(provider, ReferenceDecoder);
}
- run test to see the exception