TinyEXR.NET is a pure C# port library of tinyexr
The target frameworks are net8.0, netstandard2.1
TinyEXR.NET can be found on NuGet (← click it !)
The net8.0 target has no third-party runtime dependencies. The netstandard2.1 target depends on SharpZipLib.
- full NativeAOT support!
- Single-part EXR read/write for scanline images.
- Single-part EXR read/write for tiled images, including one-level tiles and multi-resolution mipmap/ripmap layouts.
- Multipart image EXR parse/load/save for flat image parts, including single-entry multipart containers.
- Deep single-part scanline and one-level tiled EXR load through
LoadDeepEXR. - Regular image compression support for
NONE,RLE,ZIP,ZIPS,PIZ,PXR24,B44,B44A,HTJ2K32, andHTJ2K256. - V3 deep compression support for
NONE,RLE,ZIPS, andZIP. - Layer- and multiview-aware helpers such as
EXRLayersandLoadEXRWithLayer, including RGBA expansion for subsampled channels in the convenience load path. - Managed header/image models that preserve EXR metadata needed by tools and inspectors, including data/display windows, tile descriptions, custom attributes, channel sampling, line order, and long names.
- Stateful
TinyEXR.V3reader/writer APIs for multipart, mip/rip, flat/deep, partial block reads, bounded-memory streaming writes, synchronous/asynchronous data sources, cancellation, andWouldBlockresume. - V3 HTJ2K32/HTJ2K256 flat decode and genuine encode through a safe managed JPEG 2000 Part 15 implementation.
- Safe SIMD paths for pixel conversion, RGB color matrices, and ZIP/RLE byte reorder and prediction, with scalar parity fallbacks.
- V3 spectral wavelength cubes and CPU image utilities: typed pixel conversion, whole-image and streaming resize, tone mapping, color/transfer transforms,
.cube3D LUTs, planar/interleaved bridges, and luminance-chroma reconstruction. - V3 whole-part decode for mixed flat/deep multipart files. The v1-compatible flat multipart facade returns
UnsupportedFeaturewhen a part is deep.
The TinyEXR namespace keeps the public facade close to tinyexr v1. The
TinyEXR.V3 namespace exposes the new stateful object, partial-I/O, deep, and
streaming model introduced by tinyexr v3. See
TinyEXR v3 API notes for the upstream differences, managed
type mapping, migration status, and codec support matrix.
V1-compatible facade:
ResultCodeload=Exr.LoadEXR(inputPath,outfloat[]rgba,outintwidth,outintheight);if(load!=ResultCode.Success){thrownewInvalidOperationException($"LoadEXR failed: {load}");}Direct v3 API:
usingTinyEXR.V3;ReaderResult<Image>load=ExrFile.LoadFromFile(inputPath);if(!load.IsSuccess||load.Valueis not Imageimage){thrownewInvalidOperationException($"EXR load failed: {load.Status}",load.Error);}PartfirstPart=image.Parts[0];PartLevelbaseLevel=firstPart.GetLevel(0,0);Console.WriteLine($"{firstPart.Header.PartType}: {baseLevel.Width}x{baseLevel.Height}, "+$"{baseLevel.Channels.Count} channels");WriterResultsave=ExrFile.SaveToFile(image,outputPath,Compression.ZIP);if(!save.IsSuccess){thrownewInvalidOperationException($"EXR save failed: {save.Status}",save.Error);}The repository currently includes TinyEXR.Viewer, an Avalonia sample built on top of TinyEXR.NET.
The viewer is intended for manual EXR inspection: it can open EXR files from the file picker, drag and drop, or a command-line path, preview single-part images and pure-image multipart files, switch between parts/layers/levels when decoded image data is available, and display metadata such as version flags, windows, tile information, channels, custom attributes, and deep-image statistics.
See Samples/TinyEXR.Viewer/README.md for run instructions and the current feature boundaries.
The current test suite covers the main supported surface of the library across both target outputs: the default target path and the netstandard2.1 fallback path run the same shared test cases.
See Test/README.md for the current test layout and execution details.
The current compression benchmark compares TinyEXR.NET v3, the complete
vendored TinyEXR v3 C library, and OpenEXR 3.4.13 on the same deterministic
1920x1080 RGBA HALF image. The 2026-07-26 run used BenchmarkDotNet's normal
DefaultJob and clang-cl 22.1.3 native builds. Every timed operation includes
result allocation and complete in-memory encode/decode, while preparation,
validation, and result release are excluded.
Representative means are encode ms / decode ms:
| Compression | TinyEXR.NET v3 | TinyEXR v3 C | OpenEXR 3.4.13 |
|---|---|---|---|
| None | 5.89 / 3.46 | 6.71 / 4.44 | 6.82 / 3.28 |
| RLE | 16.54 / 7.37 | 17.07 / 8.03 | 16.22 / 14.74 |
| ZIPS | 17.88 / 7.54 | 24.72 / 9.45 | 37.06 / 7.70 |
| ZIP | 11.08 / 5.45 | 19.64 / 6.43 | 22.75 / 4.55 |
| PIZ | 38.99 / 28.59 | 49.72 / 24.71 | 40.49 / 15.01 |
| PXR24 | 15.91 / 12.69 | 16.17 / 7.60 | 19.63 / 5.26 |
| HTJ2K256 | 104.28 / 82.23 | 47.77 / 33.53 | 30.35 / 24.07 |
| HTJ2K32 | 104.95 / 81.37 | 39.31 / 24.45 | 52.44 / 39.86 |
Managed encode is the fastest of the three implementations for NONE, ZIP,
ZIPS, and PIZ, with RLE and PXR24 close to both native libraries.
Managed decode leads on RLE and ZIPS. The native libraries remain
substantially faster for B44/B44A and for HTJ2K in both directions.
See Benchmark/README.md for the complete timing,
throughput, allocation, encoded-size, build, fairness, and MSVC compatibility
report.
Starting with v1.0, TinyEXR.NET is a pure C# implementation of the tinyexr-compatible API surface.
The legacy v0.3.x line is kept as a maintenance branch. It may continue to receive compatibility fixes and follow tinyexr updates when needed, but no new features will be added to v0.3.x.
The main branch moves forward with v1.0+.
For new development, prefer the mainline v1.0+ branch. Use the v0.3.x maintenance branch only if you need the legacy native-wrapper line for compatibility reasons.
- High-level RGBA helpers such as
LoadEXR,LoadEXRFromMemory,SaveEXR,SaveEXRToMemory,LoadEXRWithLayer, andEXRLayersare still the recommended entry points, so code that only uses these helpers usually needs little or no change. IsExrandIsExrFromMemoryare nowIsEXRandIsEXRFromMemory.TinyEXR.Native.*andTinyEXR.Native.EXRNativeare gone. The library is now a pure managed C# implementation, so the old native-runtime, P/Invoke, and static-link workflow fromv0.3.xno longer applies.- Native-style structs are replaced by managed types such as
ExrVersion,ExrHeader,ExrImage,ExrMultipartHeader,ExrMultipartImage,ExrDeepImage, andExrBox2i. - Low-level read/write calls are now managed
out-based APIs instead ofref-based native mutation. For example,ParseEXRHeaderFromFile(path, ref version, ref header)becomesParseEXRHeaderFromFile(path, out ExrVersion version, out ExrHeader header), andLoadEXRImageFromFile(ref image, ref header, path)becomesLoadEXRImageFromFile(path, header, out ExrImage image). SaveEXRImageToMemoryalso changed shape:v0.3.xreturnedbyte[]?, while the current API returnsResultCodeand writes the payload toout byte[] encoded.
The V3 reader materializes mixed flat/deep multipart files. The v1-compatible LoadEXRMultipartImage* model can represent only flat ExrImage parts, so it returns UnsupportedFeature when any part is deep; use TinyEXR.V3.ExrReader for those files. Likewise, v1 ExrDeepImage has no mip/rip level dimension, so LoadDeepEXR* accepts one-level deep tiles and rejects multilevel deep tiles.
The V3 reader and writer decode and genuinely encode flat HTJ2K32/HTJ2K256 payloads. Compressed deep HTJ2K data and compressed DWAA/DWAB remain intentionally unsupported, matching upstream v3 policy.
TinyEXR.NET is under MIT license