From e4c22d8f6725efd8b44492889f87a1b8ec1a587d Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 15 Mar 2026 19:55:53 +0100 Subject: [PATCH] Add tests for decode RGB and gray exr files --- .../Formats/Exr/ExrDecoderTests.cs | 24 +++++++++++++++++-- tests/ImageSharp.Tests/TestImages.cs | 2 ++ tests/Images/Input/Exr/Calliphora_gray.exr | 3 +++ tests/Images/Input/Exr/Calliphora_rgb.exr | 3 +++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/Images/Input/Exr/Calliphora_gray.exr create mode 100644 tests/Images/Input/Exr/Calliphora_rgb.exr diff --git a/tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs index 0f039f7fb0..47e9b32711 100644 --- a/tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs @@ -14,7 +14,7 @@ public class ExrDecoderTests private static MagickReferenceDecoder ReferenceDecoder => MagickReferenceDecoder.Exr; [Theory] - [InlineData(TestImages.Exr.Uncompressed, 803, 1197)] + [InlineData(TestImages.Exr.Uncompressed, 199, 297)] public void ExrDecoder_Identify_DetectsCorrectWidthAndHeight(string imagePath, int expectedWidth, int expectedHeight) { TestFile testFile = TestFile.Create(imagePath); @@ -27,7 +27,27 @@ public class ExrDecoderTests [Theory] [WithFile(TestImages.Exr.Uncompressed, PixelTypes.Rgba32)] - public void ExrDecoder_CanDecode_Uncompressed(TestImageProvider provider) + public void ExrDecoder_CanDecode_Uncompressed_RGBA(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(ExrDecoder.Instance); + image.DebugSave(provider); + image.CompareToOriginal(provider, ReferenceDecoder); + } + + [Theory] + [WithFile(TestImages.Exr.Rgb, PixelTypes.Rgba32)] + public void ExrDecoder_CanDecode_Rgb(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(ExrDecoder.Instance); + image.DebugSave(provider); + image.CompareToOriginal(provider, ReferenceDecoder); + } + + [Theory] + [WithFile(TestImages.Exr.Gray, PixelTypes.Rgba32)] + public void ExrDecoder_CanDecode_Gray(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(ExrDecoder.Instance); diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 2429c05d2b..06e35728e4 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1388,5 +1388,7 @@ public static class TestImages public const string Zips = "Exr/Calliphora_zips.exr"; public const string Rle = "Exr/Calliphora_rle.exr"; public const string B44 = "Exr/Calliphora_b44.exr"; + public const string Rgb = "Exr/Calliphora_rgb.exr"; + public const string Gray = "Exr/Calliphora_gray.exr"; } } diff --git a/tests/Images/Input/Exr/Calliphora_gray.exr b/tests/Images/Input/Exr/Calliphora_gray.exr new file mode 100644 index 0000000000..2aaeafbbe8 --- /dev/null +++ b/tests/Images/Input/Exr/Calliphora_gray.exr @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a5daadcfd4ff0e45282d39d6c54f9a13651da3fd8841abda580e76661555470 +size 124245 diff --git a/tests/Images/Input/Exr/Calliphora_rgb.exr b/tests/Images/Input/Exr/Calliphora_rgb.exr new file mode 100644 index 0000000000..5dc90343db --- /dev/null +++ b/tests/Images/Input/Exr/Calliphora_rgb.exr @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f54e5e57df1b8cdf1b26418d5696dd9cefbd7ed3bf31cdcde06fd9a7bf5e3724 +size 362681