diff --git a/src/ImageSharp/Common/Exceptions/InvalidImageContentException.cs b/src/ImageSharp/Common/Exceptions/InvalidImageContentException.cs
index 7069e89823..8be13919f1 100644
--- a/src/ImageSharp/Common/Exceptions/InvalidImageContentException.cs
+++ b/src/ImageSharp/Common/Exceptions/InvalidImageContentException.cs
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
+
namespace SixLabors.ImageSharp
{
///
@@ -18,5 +20,17 @@ namespace SixLabors.ImageSharp
: base(errorMessage)
{
}
+
+ ///
+ /// Initializes a new instance of the class with the name of the
+ /// parameter that causes this exception.
+ ///
+ /// The error message that explains the reason for this exception.
+ /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic)
+ /// if no inner exception is specified.
+ public InvalidImageContentException(string errorMessage, Exception innerException)
+ : base(errorMessage, innerException)
+ {
+ }
}
}
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
index a956f19c72..cafe101060 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
@@ -43,9 +43,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
{
Size dims = decoder.Dimensions;
- // TODO: use InvalidImageContentException here, if we decide to define it
- // https://github.com/SixLabors/ImageSharp/issues/1110
- throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}. This error can happen for very large RLE bitmaps, which are not supported.", ex);
+ throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}. This error can happen for very large RLE bitmaps, which are not supported.", ex);
}
}
diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs
index caa076553d..553163bd7e 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs
@@ -38,9 +38,10 @@ namespace SixLabors.ImageSharp.Formats.Gif
{
Size dims = decoder.Dimensions;
- // TODO: use InvalidImageContentException here, if we decide to define it
- // https://github.com/SixLabors/ImageSharp/issues/1110
- throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
+ GifThrowHelper.ThrowInvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
+
+ // Not reachable, as the previous statement will throw a exception.
+ return null;
}
}
diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
index de5aa78843..e0d8b3cd96 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
@@ -6,7 +6,7 @@ using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
-using SixLabors.ImageSharp.Advanced;
+
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
@@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// Decodes the stream to the image.
///
/// The pixel format.
- /// The stream containing image data.
+ /// The stream containing image data.
/// The decoded image
public Image Decode(Stream stream)
where TPixel : unmanaged, IPixel
@@ -241,6 +241,10 @@ namespace SixLabors.ImageSharp.Formats.Gif
this.stream.Read(this.buffer, 0, 9);
this.imageDescriptor = GifImageDescriptor.Parse(this.buffer);
+ if (this.imageDescriptor.Height == 0 || this.imageDescriptor.Width == 0)
+ {
+ GifThrowHelper.ThrowInvalidImageContentException("Width or height should not be 0");
+ }
}
///
diff --git a/src/ImageSharp/Formats/Gif/GifThrowHelper.cs b/src/ImageSharp/Formats/Gif/GifThrowHelper.cs
index 1d81008a01..1b20c9f64c 100644
--- a/src/ImageSharp/Formats/Gif/GifThrowHelper.cs
+++ b/src/ImageSharp/Formats/Gif/GifThrowHelper.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.Formats.Gif
@@ -11,8 +12,17 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// Cold path optimization for throwing 's
///
/// The error message for the exception.
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [MethodImpl(InliningOptions.ColdPath)]
public static void ThrowInvalidImageContentException(string errorMessage)
=> throw new InvalidImageContentException(errorMessage);
+
+ ///
+ /// Cold path optimization for throwing 's.
+ ///
+ /// The error message for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// if no inner exception is specified.
+ [MethodImpl(InliningOptions.ColdPath)]
+ public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException) => throw new InvalidImageContentException(errorMessage, innerException);
}
}
diff --git a/src/ImageSharp/Formats/Gif/README.md b/src/ImageSharp/Formats/Gif/README.md
index d47a4c6836..eeda20c06a 100644
--- a/src/ImageSharp/Formats/Gif/README.md
+++ b/src/ImageSharp/Formats/Gif/README.md
@@ -1,4 +1,6 @@
-Encoder/Decoder adapted and extended from:
+Encoder/Decoder adapted and extended from:
-https://github.com/yufeih/Nine.Imaging/
-https://imagetools.codeplex.com/
+- [Nine.Imaging](https://github.com/yufeih/Nine.Imaging/)
+- [imagetools.codeplex](https://imagetools.codeplex.com/)
+
+A useful set of gif test images can be found at [pygif](https://github.com/robert-ancell/pygif/tree/master/test-suite)
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
index b1144508ec..e60901d913 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
@@ -32,9 +32,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
{
(int w, int h) = (decoder.ImageWidth, decoder.ImageHeight);
- // TODO: use InvalidImageContentException here, if we decide to define it
- // https://github.com/SixLabors/ImageSharp/issues/1110
- throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {w}x{h}.", ex);
+ JpegThrowHelper.ThrowInvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {w}x{h}.", ex);
+
+ // Not reachable, as the previous statement will throw a exception.
+ return null;
}
}
diff --git a/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs b/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs
index dd44cb2d19..da4c3f9ee0 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs
@@ -15,6 +15,15 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);
+ ///
+ /// Cold path optimization for throwing 's.
+ ///
+ /// The error message for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// if no inner exception is specified.
+ [MethodImpl(InliningOptions.ColdPath)]
+ public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException) => throw new InvalidImageContentException(errorMessage, innerException);
+
///
/// Cold path optimization for throwing 's
///
diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs
index d605577e77..eceb4e592f 100644
--- a/src/ImageSharp/Formats/Png/PngDecoder.cs
+++ b/src/ImageSharp/Formats/Png/PngDecoder.cs
@@ -54,9 +54,10 @@ namespace SixLabors.ImageSharp.Formats.Png
{
Size dims = decoder.Dimensions;
- // TODO: use InvalidImageContentException here, if we decide to define it
- // https://github.com/SixLabors/ImageSharp/issues/1110
- throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
+ PngThrowHelper.ThrowInvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
+
+ // Not reachable, as the previous statement will throw a exception.
+ return null;
}
}
diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs
index 341fc53edf..1e4567548b 100644
--- a/src/ImageSharp/Formats/Png/PngMetadata.cs
+++ b/src/ImageSharp/Formats/Png/PngMetadata.cs
@@ -91,34 +91,12 @@ namespace SixLabors.ImageSharp.Formats.Png
public bool HasTransparency { get; set; }
///
- /// Gets or sets the collection of text data stored within the iTXt, tEXt, and zTXt chunks.
+ /// Gets or sets the collection of text data stored within the iTXt, tEXt, and zTXt chunks.
/// Used for conveying textual information associated with the image.
///
public IList TextData { get; set; } = new List();
- ///
- /// Gets the list of png text properties for storing meta information about this image.
- ///
- public IList PngTextProperties { get; } = new List();
-
///
public IDeepCloneable DeepClone() => new PngMetadata(this);
-
- internal bool TryGetPngTextProperty(string keyword, out PngTextData result)
- {
- for (int i = 0; i < this.TextData.Count; i++)
- {
- if (this.TextData[i].Keyword == keyword)
- {
- result = this.TextData[i];
-
- return true;
- }
- }
-
- result = default;
-
- return false;
- }
}
}
diff --git a/src/ImageSharp/Formats/Png/PngThrowHelper.cs b/src/ImageSharp/Formats/Png/PngThrowHelper.cs
index b0a2571eae..a72a4a0d88 100644
--- a/src/ImageSharp/Formats/Png/PngThrowHelper.cs
+++ b/src/ImageSharp/Formats/Png/PngThrowHelper.cs
@@ -11,6 +11,10 @@ namespace SixLabors.ImageSharp.Formats.Png
///
internal static class PngThrowHelper
{
+ [MethodImpl(InliningOptions.ColdPath)]
+ public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException)
+ => throw new InvalidImageContentException(errorMessage, innerException);
+
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowNoHeader() => throw new InvalidImageContentException("PNG Image does not contain a header chunk");
diff --git a/src/ImageSharp/Formats/Tga/TgaDecoder.cs b/src/ImageSharp/Formats/Tga/TgaDecoder.cs
index c3b8526ceb..64dbdf58a9 100644
--- a/src/ImageSharp/Formats/Tga/TgaDecoder.cs
+++ b/src/ImageSharp/Formats/Tga/TgaDecoder.cs
@@ -28,9 +28,10 @@ namespace SixLabors.ImageSharp.Formats.Tga
{
Size dims = decoder.Dimensions;
- // TODO: use InvalidImageContentException here, if we decide to define it
- // https://github.com/SixLabors/ImageSharp/issues/1110
- throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
+ TgaThrowHelper.ThrowInvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
+
+ // Not reachable, as the previous statement will throw a exception.
+ return null;
}
}
diff --git a/src/ImageSharp/Formats/Tga/TgaThrowHelper.cs b/src/ImageSharp/Formats/Tga/TgaThrowHelper.cs
index 1714a2025e..fc158e781e 100644
--- a/src/ImageSharp/Formats/Tga/TgaThrowHelper.cs
+++ b/src/ImageSharp/Formats/Tga/TgaThrowHelper.cs
@@ -12,15 +12,25 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// Cold path optimization for throwing 's
///
/// The error message for the exception.
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [MethodImpl(InliningOptions.ColdPath)]
public static void ThrowInvalidImageContentException(string errorMessage)
=> throw new InvalidImageContentException(errorMessage);
+ ///
+ /// Cold path optimization for throwing 's
+ ///
+ /// The error message for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// if no inner exception is specified.
+ [MethodImpl(InliningOptions.ColdPath)]
+ public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException)
+ => throw new InvalidImageContentException(errorMessage, innerException);
+
///
/// Cold path optimization for throwing 's
///
/// The error message for the exception.
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [MethodImpl(InliningOptions.ColdPath)]
public static void ThrowNotSupportedException(string errorMessage)
=> throw new NotSupportedException(errorMessage);
}
diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
index 85cdf6d11a..f63fc0a16a 100644
--- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
@@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
where TPixel : unmanaged, IPixel
{
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10);
- ImageFormatException ex = Assert.Throws(() => provider.GetImage(BmpDecoder));
+ InvalidImageContentException ex = Assert.Throws(() => provider.GetImage(BmpDecoder));
Assert.IsType(ex.InnerException);
}
diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
index b3a99aa1c0..12d890357a 100644
--- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
@@ -2,11 +2,9 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using System.Collections.Generic;
using System.IO;
using Microsoft.DotNet.RemoteExecutor;
-using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata;
@@ -30,32 +28,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
TestImages.Gif.Giphy, TestImages.Gif.Kumin
};
- public static readonly string[] BasicVerificationFiles =
- {
- TestImages.Gif.Cheers,
- TestImages.Gif.Rings,
-
- // previously DecodeBadApplicationExtensionLength:
- TestImages.Gif.Issues.BadAppExtLength,
- TestImages.Gif.Issues.BadAppExtLength_2,
-
- // previously DecodeBadDescriptorDimensionsLength:
- TestImages.Gif.Issues.BadDescriptorWidth
- };
-
- private static readonly Dictionary BasicVerificationFrameCount =
- new Dictionary
- {
- [TestImages.Gif.Cheers] = 93,
- [TestImages.Gif.Issues.BadDescriptorWidth] = 36,
- };
-
- public static readonly string[] BadAppExtFiles =
- {
- TestImages.Gif.Issues.BadAppExtLength,
- TestImages.Gif.Issues.BadAppExtLength_2
- };
-
[Theory]
[WithFileCollection(nameof(MultiFrameTestFiles), PixelTypes.Rgba32)]
public void Decode_VerifyAllFrames(TestImageProvider provider)
@@ -100,15 +72,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
}
[Theory]
- [WithFileCollection(nameof(BasicVerificationFiles), PixelTypes.Rgba32)]
- public void Decode_VerifyRootFrameAndFrameCount(TestImageProvider provider)
+ [WithFile(TestImages.Gif.Cheers, PixelTypes.Rgba32, 93)]
+ [WithFile(TestImages.Gif.Rings, PixelTypes.Rgba32, 1)]
+ [WithFile(TestImages.Gif.Issues.BadDescriptorWidth, PixelTypes.Rgba32, 36)]
+ public void Decode_VerifyRootFrameAndFrameCount(TestImageProvider provider, int expectedFrameCount)
where TPixel : unmanaged, IPixel
{
- if (!BasicVerificationFrameCount.TryGetValue(provider.SourceFileOrDescription, out int expectedFrameCount))
- {
- expectedFrameCount = 1;
- }
-
using (Image image = provider.GetImage())
{
Assert.Equal(expectedFrameCount, image.Frames.Count);
@@ -153,6 +122,35 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
}
}
+ [Theory]
+ [WithFile(TestImages.Gif.ZeroSize, PixelTypes.Rgba32)]
+ [WithFile(TestImages.Gif.ZeroWidth, PixelTypes.Rgba32)]
+ [WithFile(TestImages.Gif.ZeroHeight, PixelTypes.Rgba32)]
+ public void Decode_WithInvalidDimensions_DoesThrowException(TestImageProvider provider)
+ where TPixel : unmanaged, IPixel
+ {
+ System.Exception ex = Record.Exception(
+ () =>
+ {
+ using Image image = provider.GetImage(GifDecoder);
+ });
+ Assert.NotNull(ex);
+ Assert.Contains("Width or height should not be 0", ex.Message);
+ }
+
+ [Theory]
+ [WithFile(TestImages.Gif.MaxWidth, PixelTypes.Rgba32, 65535, 1)]
+ [WithFile(TestImages.Gif.MaxHeight, PixelTypes.Rgba32, 1, 65535)]
+ public void Decode_WithMaxDimensions_Works(TestImageProvider provider, int expectedWidth, int expectedHeight)
+ where TPixel : unmanaged, IPixel
+ {
+ using (Image image = provider.GetImage(GifDecoder))
+ {
+ Assert.Equal(expectedWidth, image.Width);
+ Assert.Equal(expectedHeight, image.Height);
+ }
+ }
+
[Fact]
public void CanDecodeIntermingledImages()
{
@@ -172,6 +170,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
}
}
+ // https://github.com/SixLabors/ImageSharp/issues/405
+ [Theory]
+ [WithFile(TestImages.Gif.Issues.BadAppExtLength, PixelTypes.Rgba32)]
+ [WithFile(TestImages.Gif.Issues.BadAppExtLength_2, PixelTypes.Rgba32)]
+ public void Issue405_BadApplicationExtensionBlockLength(TestImageProvider provider)
+ where TPixel : unmanaged, IPixel
+ {
+ using (Image image = provider.GetImage())
+ {
+ image.DebugSave(provider);
+ image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider);
+ }
+ }
+
[Theory]
[WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)]
[WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)]
@@ -179,7 +191,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
where TPixel : unmanaged, IPixel
{
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10);
- ImageFormatException ex = Assert.Throws(() => provider.GetImage(GifDecoder));
+ InvalidImageContentException ex = Assert.Throws(() => provider.GetImage(GifDecoder));
Assert.IsType(ex.InnerException);
}
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
index 25cf5dd376..a35bb177ce 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
@@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
where TPixel : unmanaged, IPixel
{
provider.LimitAllocatorBufferCapacity().InBytesSqrt(10);
- ImageFormatException ex = Assert.Throws(() => provider.GetImage(JpegDecoder));
+ InvalidImageContentException ex = Assert.Throws(() => provider.GetImage(JpegDecoder));
this.Output.WriteLine(ex.Message);
Assert.IsType(ex.InnerException);
}
diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
index 6eb6e93db8..72b27ec5d6 100644
--- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
@@ -397,7 +397,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
where TPixel : unmanaged, IPixel
{
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10);
- ImageFormatException ex = Assert.Throws(() => provider.GetImage(PngDecoder));
+ InvalidImageContentException ex = Assert.Throws(() => provider.GetImage(PngDecoder));
Assert.IsType(ex.InnerException);
}
diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs
index 840bb55f20..6f886b73df 100644
--- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs
@@ -740,7 +740,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
where TPixel : unmanaged, IPixel
{
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10);
- ImageFormatException ex = Assert.Throws(() => provider.GetImage(TgaDecoder));
+ InvalidImageContentException ex = Assert.Throws(() => provider.GetImage(TgaDecoder));
Assert.IsType(ex.InnerException);
}
diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs
index bec0c66242..141a8d1c38 100644
--- a/tests/ImageSharp.Tests/TestImages.cs
+++ b/tests/ImageSharp.Tests/TestImages.cs
@@ -397,6 +397,13 @@ namespace SixLabors.ImageSharp.Tests
public const string Ratio1x4 = "Gif/base_1x4.gif";
public const string LargeComment = "Gif/large_comment.gif";
+ // Test images from https://github.com/robert-ancell/pygif/tree/master/test-suite
+ public const string ZeroSize = "Gif/image-zero-size.gif";
+ public const string ZeroHeight = "Gif/image-zero-height.gif";
+ public const string ZeroWidth = "Gif/image-zero-width.gif";
+ public const string MaxWidth = "Gif/max-width.gif";
+ public const string MaxHeight = "Gif/max-height.gif";
+
public static class Issues
{
public const string BadAppExtLength = "Gif/issues/issue405_badappextlength252.gif";
diff --git a/tests/Images/External b/tests/Images/External
index 6fdc6d19b1..0d1f91e2fe 160000
--- a/tests/Images/External
+++ b/tests/Images/External
@@ -1 +1 @@
-Subproject commit 6fdc6d19b101dc1c00a297d3e92257df60c413d0
+Subproject commit 0d1f91e2fe1491f6dc2c137a8ea20460fde4404c
diff --git a/tests/Images/Input/Gif/image-zero-height.gif b/tests/Images/Input/Gif/image-zero-height.gif
new file mode 100644
index 0000000000..f4f70ab6a4
--- /dev/null
+++ b/tests/Images/Input/Gif/image-zero-height.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:37248eeb127e43bb002f621409cb6dabaa6b58a62612d26009722c4ae7c83dd6
+size 30
diff --git a/tests/Images/Input/Gif/image-zero-size.gif b/tests/Images/Input/Gif/image-zero-size.gif
new file mode 100644
index 0000000000..c2bccffc49
--- /dev/null
+++ b/tests/Images/Input/Gif/image-zero-size.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:518aa6f50b003b76e8b65e798d2a37b6dad7dade96d0a7db73da88eec07efe0e
+size 30
diff --git a/tests/Images/Input/Gif/image-zero-width.gif b/tests/Images/Input/Gif/image-zero-width.gif
new file mode 100644
index 0000000000..642be49ad4
--- /dev/null
+++ b/tests/Images/Input/Gif/image-zero-width.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4cde31fe4bcc863f70f66c5a57d62647b11512920328fc5658399ef566ebebef
+size 30
diff --git a/tests/Images/Input/Gif/max-height.gif b/tests/Images/Input/Gif/max-height.gif
new file mode 100644
index 0000000000..fcec4bd936
--- /dev/null
+++ b/tests/Images/Input/Gif/max-height.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8853634077f425f4b2077f4ca0c986e4ac0e549a8601859b0578a3ccbdbdd5d4
+size 405
diff --git a/tests/Images/Input/Gif/max-width.gif b/tests/Images/Input/Gif/max-width.gif
new file mode 100644
index 0000000000..bb0e131acc
--- /dev/null
+++ b/tests/Images/Input/Gif/max-width.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:008e2a84afed6c31b6635aa9d8c7ee2176f01a0eb0a04143883a8533d7ca33c9
+size 405