Skip to content

Add support for OpenEXR image format#3096

Open
brianpopow wants to merge 98 commits intomainfrom
bp/openExr
Open

Add support for OpenEXR image format#3096
brianpopow wants to merge 98 commits intomainfrom
bp/openExr

Conversation

@brianpopow
Copy link
Copy Markdown
Collaborator

@brianpopow brianpopow commented Mar 29, 2026

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This PR adds support for decoding and encoding of images in the OpenEXR format. OpenEXR is a HDR image format, therefore I have added two new pixel formats Rgb96 and Rgba128 which store each color channel as UInt32.

The specification can be found here: https://openexr.com/en/latest/index.html#openexr

A reference implementation can be found here: https://github.com/AcademySoftwareFoundation/openexr.git

# Conflicts:
#	src/ImageSharp/Configuration.cs
# Conflicts:
#	src/ImageSharp/Formats/Bmp/BmpConstants.cs
#	src/ImageSharp/Formats/Bmp/BmpDecoder.cs
#	src/ImageSharp/Formats/Bmp/BmpFormat.cs
# Conflicts:
#	src/ImageSharp/Configuration.cs
#	src/ImageSharp/Formats/Bmp/BmpArrayFileHeader.cs
#	src/ImageSharp/Formats/Bmp/BmpConstants.cs
#	src/ImageSharp/Formats/Bmp/BmpFormat.cs
#	src/ImageSharp/Formats/Bmp/BmpImageFormatDetector.cs
#	src/ImageSharp/Formats/ImageExtensions.Save.cs
#	src/ImageSharp/Formats/Pbm/BufferedReadStreamExtensions.cs
#	tests/ImageSharp.Tests/ConfigurationTests.cs
#	tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
# Conflicts:
#	src/ImageSharp/Configuration.cs
#	src/ImageSharp/Formats/Bmp/BmpArrayFileHeader.cs
#	src/ImageSharp/Formats/Bmp/BmpConstants.cs
#	src/ImageSharp/Formats/Bmp/BmpDecoder.cs
#	src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
#	src/ImageSharp/Formats/Bmp/BmpFileHeader.cs
#	src/ImageSharp/Formats/Bmp/BmpFormat.cs
#	src/ImageSharp/Formats/Bmp/BmpImageFormatDetector.cs
#	src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs
#	src/ImageSharp/Formats/ImageDecoderUtilities.cs
#	src/ImageSharp/Formats/ImageExtensions.Save.cs
#	src/ImageSharp/Formats/Pbm/BufferedReadStreamExtensions.cs
#	src/ImageSharp/Image.Decode.cs
#	tests/ImageSharp.Tests/ConfigurationTests.cs
#	tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
# Conflicts:
#	src/ImageSharp/Formats/Bmp/BmpFormat.cs
#	src/ImageSharp/Formats/ImageDecoderUtilities.cs
#	src/ImageSharp/Formats/ImageExtensions.Save.cs
#	src/ImageSharp/Formats/OpenExr/ExrDecoderCore.cs
# Conflicts:
#	src/ImageSharp/Configuration.cs
#	src/ImageSharp/Formats/ImageDecoderUtilities.cs
#	tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs

namespace SixLabors.ImageSharp.Formats.Exr.Compression;

internal abstract class ExrBaseDecompressor : ExrBaseCompression
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know these types are internal but I'm finding it very useful currently to document the crap out of everything (AI really helps here.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added more docs with 1e69aa4

@brianpopow
Copy link
Copy Markdown
Collaborator Author

@brianpopow I'll be able to focus on a proper review this week.

@JimBobSquarePants: dont worry keep your time, it is not urgent.

Just as a heads up: I noticed issues with the pixel conversion methods introduced with the new pixel types. I am trying to add tests for them in the next days. Those conversion methods will change, so maybe exclude them from a review until then, because they will change anyway.

Comment thread tests/ImageSharp.Tests/PixelFormats/Rgb96Tests.cs Fixed
Comment thread tests/ImageSharp.Tests/PixelFormats/Rgb96Tests.cs Dismissed
Comment thread tests/ImageSharp.Tests/PixelFormats/Rgba128Tests.cs Dismissed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output looks bugged to me. Has the Magick comparison been hiding an issue?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image looks like this:
pal4rlecut

The image is from the bmp suite where alot of the edge case image in the tests come from.

From the description of the image:

An RLE-compressed image that uses “delta” codes, and early EOL & EOBMP markers, to skip over some pixels. It’s okay if the viewer’s image doesn’t exactly match any of the reference images.

It looks like the third image in the "correct display" list: the undefined pixels are black.

Comment thread src/ImageSharp/Formats/Exr/ExrDecoderCore.cs Fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

formats:exr Any PR or issue related to OpenExr file format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants