{"id":13532018,"url":"https://github.com/syoyo/tinyexr","last_synced_at":"2026-04-02T19:38:20.554Z","repository":{"id":20130046,"uuid":"23400110","full_name":"syoyo/tinyexr","owner":"syoyo","description":"Tiny OpenEXR image loader/saver library","archived":false,"fork":false,"pushed_at":"2025-03-26T16:42:23.000Z","size":25534,"stargazers_count":739,"open_issues_count":11,"forks_count":148,"subscribers_count":30,"default_branch":"release","last_synced_at":"2025-04-13T20:41:16.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syoyo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"syoyo","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2014-08-27T18:09:27.000Z","updated_at":"2025-04-13T07:25:36.000Z","dependencies_parsed_at":"2024-01-03T04:01:33.620Z","dependency_job_id":"ab725ea0-7d4d-4d98-a017-847cda95cd1a","html_url":"https://github.com/syoyo/tinyexr","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinyexr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinyexr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinyexr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinyexr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syoyo","download_url":"https://codeload.github.com/syoyo/tinyexr/tar.gz/refs/heads/release","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249197,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:07.625Z","updated_at":"2026-04-02T19:38:20.548Z","avatar_url":"https://github.com/syoyo.png","language":"C++","readme":"# Tiny OpenEXR image library.\n\n![Example](https://github.com/syoyo/tinyexr/blob/release/asakusa.png?raw=true)\n\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/k07ftfe4ph057qau/branch/release?svg=true)](https://ci.appveyor.com/project/syoyo/tinyexr/branch/release)\n\n[![Coverity Scan Build Status](https://scan.coverity.com/projects/5827/badge.svg)](https://scan.coverity.com/projects/5827)\n\n`tinyexr` is a small, single header-only library to load and save OpenEXR (.exr) images.\n`tinyexr` is written in portable C++ (no library dependency except for STL), thus `tinyexr` is good to embed into your application.\nTo use `tinyexr`, simply copy `tinyexr.h`, `miniz.c` and `miniz.h`(for zlib. You can use system-installed zlib instead of miniz, or the zlib implementation included in `stb_image[_write].h`. Controlled with `TINYEXR_USE_MINIZ` and `TINYEXR_USE_STB_ZLIB` compile flags) into your project.\n\n# Security\n\nTinyEXR does not use C++ exception.\n\nTinyEXR now does not use `assert` from v1.0.4(2023/06/04), except for miniz's assert.\n(We plan to use wuff's zlib for better security and performance)\n\nTinyEXR is fuzz tested and **currently no security issues**(No seg fault for any malcious/corrupted input EXR data) as of v1.0.7.\n\n# Features\n\nCurrent status of `tinyexr` is:\n\n- OpenEXR v1 image\n  - [x] Scanline format\n  - [x] Tiled format\n    - [x] Tile format with no LoD (load).\n    - [x] Tile format with LoD (load).\n    - [x] Tile format with no LoD (save).\n    - [x] Tile format with LoD (save).\n  - [x] Custom attributes\n- OpenEXR v2 image\n  - [ ] Multipart format\n    - [x] Load multi-part image\n    - [x] Save multi-part image\n    - [ ] Load multi-part deep image\n    - [ ] Save multi-part deep image\n  - [ ] deepscanline \n- OpenEXR v2 deep image\n  - [x] Loading scanline + ZIPS + HALF or FLOAT pixel type.\n- Compression\n  - [x] NONE\n  - [x] RLE\n  - [x] ZIP\n  - [x] ZIPS\n  - [x] PIZ\n  - [x] ZFP (tinyexr extension)\n  - [x] B44/B44A (OpenEXR compatible)\n  - [x] PXR24 (OpenEXR compatible)\n  - [ ] DWA (not planned, patent encumbered)\n- Spectral EXR (JCGT 2021)\n  - [x] Emissive spectra (S{n}.{wavelength}nm)\n  - [x] Reflective spectra (T.{wavelength}nm)\n  - [x] Polarised spectra (Stokes S0-S3)\n- Line order.\n  - [x] Increasing, decreasing (load)\n  - [ ] Random?\n  - [x] Increasing (save)\n  - [ ] decreasing (save)\n- Pixel format (UINT, FLOAT).\n  - [x] UINT, FLOAT (load)\n  - [x] UINT, FLOAT (deep load)\n  - [x] UINT, FLOAT (save)\n  - [ ] UINT, FLOAT (deep save)\n- Support for big endian machine.\n  - [x] Loading scanline image\n  - [x] Saving scanline image\n  - [x] Loading multi-part channel EXR (not tested)\n  - [x] Saving multi-part channel EXR (not tested)\n  - [ ] Loading deep image\n  - [ ] Saving deep image\n- Optimization\n  - [x] C++11 thread loading\n  - [ ] C++11 thread saving\n  - [ ] ISPC?\n  - [x] OpenMP multi-threading in EXR loading.\n  - [x] OpenMP multi-threading in EXR saving.\n  - [ ] OpenMP multi-threading in deep image loading.\n  - [ ] OpenMP multi-threading in deep image saving.\n* C interface.\n  * You can easily write language bindings (e.g. golang)\n\n# Supported platform\n\n* [x] x86-64\n  * [x] Windows 7 or later\n  * [x] Linux(posix) system\n  * [x] macOS\n* [x] AARCH64\n  * [x] aarch64 linux(e.g. Raspberry Pi)\n  * [x] Android\n  * [x] iOS\n  * [x] macOS\n* [ ] RISC-V(Should work)\n* [x] Big endian machine(not maintained, but should work)\n  * SPARC, PowerPC, ...\n* [x] WebAssembly(JavaScript)\n  * Loader only(See ![js](experimental/js/))\n* [x] Python binding\n  * Loader only https://pypi.org/project/pytinyexr/\n\n# Requirements\n\n* C++ compiler(C++11 recommended. C++03 may work)\n\n# Use case\n\n## New TinyEXR (v0.9.5+)\n\n* Godot. Multi-platform 2D and 3D game engine https://godotengine.org/\n* Filament. PBR engine(used in a converter tool). https://github.com/google/filament\n* PyEXR. Loading OpenEXR (.exr) images using Python. https://github.com/ialhashim/PyEXR\n* The-Forge. The Forge Cross-Platform Rendering Framework PC, Linux, Ray Tracing, macOS / iOS, Android, XBOX, PS4 https://github.com/ConfettiFX/The-Forge\n* psdr-cuda. Path-space differentiable renderer. https://github.com/uci-rendering/psdr-cuda\n* Studying Microfacets BSDFs https://virtualgonio.pages.xlim.fr/\n* Your project here!\n\n## Older TinyEXR (v0.9.0)\n\n* mallie https://github.com/lighttransport/mallie\n* Cinder 0.9.0 https://libcinder.org/notes/v0.9.0\n* Piccante (develop branch) http://piccantelib.net/\n* Your project here!\n\n## Examples\n\n* [examples/deepview/](examples/deepview) Deep image view\n* [examples/rgbe2exr/](examples/rgbe2exr) .hdr to EXR converter\n* [examples/exr2rgbe/](examples/exr2rgbe) EXR to .hdr converter\n* [examples/ldr2exr/](examples/exr2rgbe) LDR to EXR converter\n* [examples/exr2ldr/](examples/exr2ldr) EXR to LDR converter\n* [examples/exr2fptiff/](examples/exr2fptiff) EXR to 32bit floating point TIFF converter\n  * for 32bit floating point TIFF to EXR convert, see https://github.com/syoyo/tinydngloader/tree/release/examples/fptiff2exr\n* [examples/cube2longlat/](examples/cube2longlat) Cubemap to longlat (equirectangler) converter\n* [examples/spectral/](examples/spectral) Spectral EXR read/write example\n\n## Experimental\n\n* [experimental/js/](experimental/js) JavaScript port using Emscripten\n\n## Usage\n\nNOTE: **API is still subject to change**. See the source code for details.\n\nInclude `tinyexr.h` with `TINYEXR_IMPLEMENTATION` flag (do this only for **one** .cc file).\n\n```cpp\n//Please include your own zlib-compatible API header before\n//including `tinyexr.h` when you disable `TINYEXR_USE_MINIZ`\n//#define TINYEXR_USE_MINIZ 0\n//#include \"zlib.h\"\n//Or, if your project uses `stb_image[_write].h`, use their\n//zlib implementation:\n//#define TINYEXR_USE_STB_ZLIB 1\n#define TINYEXR_IMPLEMENTATION\n#include \"tinyexr.h\"\n```\n\n### Compile flags\n\n* `TINYEXR_USE_MINIZ` Use miniz (default = 1). Please include `zlib.h` header before `tinyexr.h` if you disable miniz support(e.g. use system's zlib).\n* `TINYEXR_USE_STB_ZLIB` Use zlib from `stb_image[_write].h` instead of miniz or the system's zlib (default = 0).\n* `TINYEXR_USE_PIZ` Enable PIZ compression support (default = 1)\n* `TINYEXR_USE_ZFP` Enable ZFP compression support (TinyEXR extension, default = 0)\n* `TINYEXR_USE_THREAD` Enable threaded loading/storing using C++11 thread (Requires C++11 compiler, default = 0)\n  * Use `TINYEXR_MAX_THREADS` over 0 to use MIN(TINYEXR_MAX_THREADS,hardware_concurrency()) in stead off hardware_concurrency(). (default = 0)\n* `TINYEXR_USE_OPENMP` Enable OpenMP threading support (default = 1 if `_OPENMP` is defined)\n  * Use `TINYEXR_USE_OPENMP=0` to force disable OpenMP code path even if OpenMP is available/enabled in the compiler.\n* `TINYEXR_USE_COMPILER_FP16` Enable use of compiler provided FP16\u003c\u003eFP32 conversions when available (default = 0)\n\n### Quickly reading RGB(A) EXR file.\n\n```cpp\n  const char* input = \"asakusa.exr\";\n  float* out; // width * height * RGBA\n  int width;\n  int height;\n  const char* err = NULL; // or nullptr in C++11\n\n  int ret = LoadEXR(\u0026out, \u0026width, \u0026height, input, \u0026err);\n\n  if (ret != TINYEXR_SUCCESS) {\n    if (err) {\n       fprintf(stderr, \"ERR : %s\\n\", err);\n       FreeEXRErrorMessage(err); // release memory of error message.\n    }\n  } else {\n    ...\n    free(out); // release memory of image data\n  }\n\n```\n\n### Reading layered RGB(A) EXR file.\n\nIf you want to read EXR image with layer info (channel has a name with delimiter `.`), please use `LoadEXRWithLayer` API.\n\nYou need to know layer name in advance (e.g. through `EXRLayers` API).\n\n```cpp\n  const char* input = ...;\n  const char* layer_name = \"diffuse\"; // or use EXRLayers to get list of layer names in .exr\n  float* out; // width * height * RGBA\n  int width;\n  int height;\n  const char* err = NULL; // or nullptr in C++11\n\n  // will read `diffuse.R`, `diffuse.G`, `diffuse.B`, (`diffuse.A`) channels\n  int ret = LoadEXRWithLayer(\u0026out, \u0026width, \u0026height, input, layer_name, \u0026err);\n\n  if (ret != TINYEXR_SUCCESS) {\n    if (err) {\n       fprintf(stderr, \"ERR : %s\\n\", err);\n       FreeEXRErrorMessage(err); // release memory of error message.\n    }\n  } else {\n    ...\n    free(out); // release memory of image data\n  }\n\n```\n\n### Loading Singlepart EXR from a file.\n\nScanline and tiled format are supported.\n\n```cpp\n  // 1. Read EXR version.\n  EXRVersion exr_version;\n\n  int ret = ParseEXRVersionFromFile(\u0026exr_version, argv[1]);\n  if (ret != 0) {\n    fprintf(stderr, \"Invalid EXR file: %s\\n\", argv[1]);\n    return -1;\n  }\n\n  if (exr_version.multipart) {\n    // must be multipart flag is false.\n    return -1;\n  }\n\n  // 2. Read EXR header\n  EXRHeader exr_header;\n  InitEXRHeader(\u0026exr_header);\n\n  const char* err = NULL; // or `nullptr` in C++11 or later.\n  ret = ParseEXRHeaderFromFile(\u0026exr_header, \u0026exr_version, argv[1], \u0026err);\n  if (ret != 0) {\n    fprintf(stderr, \"Parse EXR err: %s\\n\", err);\n    FreeEXRErrorMessage(err); // free's buffer for an error message\n    return ret;\n  }\n\n  // // Read HALF channel as FLOAT.\n  // for (int i = 0; i \u003c exr_header.num_channels; i++) {\n  //   if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) {\n  //     exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;\n  //   }\n  // }\n\n  EXRImage exr_image;\n  InitEXRImage(\u0026exr_image);\n\n  ret = LoadEXRImageFromFile(\u0026exr_image, \u0026exr_header, argv[1], \u0026err);\n  if (ret != 0) {\n    fprintf(stderr, \"Load EXR err: %s\\n\", err);\n    FreeEXRHeader(\u0026exr_header);\n    FreeEXRErrorMessage(err); // free's buffer for an error message\n    return ret;\n  }\n\n  // 3. Access image data\n  // `exr_image.images` will be filled when EXR is scanline format.\n  // `exr_image.tiled` will be filled when EXR is tiled format.\n\n  // 4. Free image data\n  FreeEXRImage(\u0026exr_image);\n  FreeEXRHeader(\u0026exr_header);\n```\n\n### Loading Multipart EXR from a file.\n\nScanline and tiled format are supported.\n\n```cpp\n  // 1. Read EXR version.\n  EXRVersion exr_version;\n\n  int ret = ParseEXRVersionFromFile(\u0026exr_version, argv[1]);\n  if (ret != 0) {\n    fprintf(stderr, \"Invalid EXR file: %s\\n\", argv[1]);\n    return -1;\n  }\n\n  if (!exr_version.multipart) {\n    // must be multipart flag is true.\n    return -1;\n  }\n\n  // 2. Read EXR headers in the EXR.\n  EXRHeader **exr_headers; // list of EXRHeader pointers.\n  int num_exr_headers;\n  const char *err = NULL; // or nullptr in C++11 or later\n\n  // Memory for EXRHeader is allocated inside of ParseEXRMultipartHeaderFromFile,\n  ret = ParseEXRMultipartHeaderFromFile(\u0026exr_headers, \u0026num_exr_headers, \u0026exr_version, argv[1], \u0026err);\n  if (ret != 0) {\n    fprintf(stderr, \"Parse EXR err: %s\\n\", err);\n    FreeEXRErrorMessage(err); // free's buffer for an error message\n    return ret;\n  }\n\n  printf(\"num parts = %d\\n\", num_exr_headers);\n\n\n  // 3. Load images.\n\n  // Prepare array of EXRImage.\n  std::vector\u003cEXRImage\u003e images(num_exr_headers);\n  for (int i =0; i \u003c num_exr_headers; i++) {\n    InitEXRImage(\u0026images[i]);\n  }\n\n  ret = LoadEXRMultipartImageFromFile(\u0026images.at(0), const_cast\u003cconst EXRHeader**\u003e(exr_headers), num_exr_headers, argv[1], \u0026err);\n  if (ret != 0) {\n    fprintf(stderr, \"Parse EXR err: %s\\n\", err);\n    FreeEXRErrorMessage(err); // free's buffer for an error message\n    return ret;\n  }\n\n  printf(\"Loaded %d part images\\n\", num_exr_headers);\n\n  // 4. Access image data\n  // `exr_image.images` will be filled when EXR is scanline format.\n  // `exr_image.tiled` will be filled when EXR is tiled format.\n\n  // 5. Free images\n  for (int i =0; i \u003c num_exr_headers; i++) {\n    FreeEXRImage(\u0026images.at(i));\n  }\n\n  // 6. Free headers.\n  for (int i =0; i \u003c num_exr_headers; i++) {\n    FreeEXRHeader(exr_headers[i]);\n    free(exr_headers[i]);\n  }\n  free(exr_headers);\n```\n\n\nSaving Scanline EXR file.\n\n```cpp\n  // See `examples/rgbe2exr/` for more details.\n  bool SaveEXR(const float* rgb, int width, int height, const char* outfilename) {\n\n    EXRHeader header;\n    InitEXRHeader(\u0026header);\n\n    EXRImage image;\n    InitEXRImage(\u0026image);\n\n    image.num_channels = 3;\n\n    std::vector\u003cfloat\u003e images[3];\n    images[0].resize(width * height);\n    images[1].resize(width * height);\n    images[2].resize(width * height);\n\n    // Split RGBRGBRGB... into R, G and B layer\n    for (int i = 0; i \u003c width * height; i++) {\n      images[0][i] = rgb[3*i+0];\n      images[1][i] = rgb[3*i+1];\n      images[2][i] = rgb[3*i+2];\n    }\n\n    float* image_ptr[3];\n    image_ptr[0] = \u0026(images[2].at(0)); // B\n    image_ptr[1] = \u0026(images[1].at(0)); // G\n    image_ptr[2] = \u0026(images[0].at(0)); // R\n\n    image.images = (unsigned char**)image_ptr;\n    image.width = width;\n    image.height = height;\n\n    header.num_channels = 3;\n    header.channels = (EXRChannelInfo *)malloc(sizeof(EXRChannelInfo) * header.num_channels);\n    // Must be (A)BGR order, since most of EXR viewers expect this channel order.\n    strncpy(header.channels[0].name, \"B\", 255); header.channels[0].name[strlen(\"B\")] = '\\0';\n    strncpy(header.channels[1].name, \"G\", 255); header.channels[1].name[strlen(\"G\")] = '\\0';\n    strncpy(header.channels[2].name, \"R\", 255); header.channels[2].name[strlen(\"R\")] = '\\0';\n\n    header.pixel_types = (int *)malloc(sizeof(int) * header.num_channels);\n    header.requested_pixel_types = (int *)malloc(sizeof(int) * header.num_channels);\n    for (int i = 0; i \u003c header.num_channels; i++) {\n      header.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image\n      header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in .EXR\n    }\n\n    const char* err = NULL; // or nullptr in C++11 or later.\n    int ret = SaveEXRImageToFile(\u0026image, \u0026header, outfilename, \u0026err);\n    if (ret != TINYEXR_SUCCESS) {\n      fprintf(stderr, \"Save EXR err: %s\\n\", err);\n      FreeEXRErrorMessage(err); // free's buffer for an error message\n      return ret;\n    }\n    printf(\"Saved exr file. [ %s ] \\n\", outfilename);\n\n    free(rgb);\n\n    free(header.channels);\n    free(header.pixel_types);\n    free(header.requested_pixel_types);\n\n  }\n```\n\n\nReading deep image EXR file.\nSee `example/deepview` for actual usage.\n\n```cpp\n  const char* input = \"deepscanline.exr\";\n  const char* err = NULL; // or nullptr\n  DeepImage deepImage;\n\n  int ret = LoadDeepEXR(\u0026deepImage, input, \u0026err);\n\n  // access to each sample in the deep pixel.\n  for (int y = 0; y \u003c deepImage.height; y++) {\n    int sampleNum = deepImage.offset_table[y][deepImage.width-1];\n    for (int x = 0; x \u003c deepImage.width-1; x++) {\n      int s_start = deepImage.offset_table[y][x];\n      int s_end   = deepImage.offset_table[y][x+1];\n      if (s_start \u003e= sampleNum) {\n        continue;\n      }\n      s_end = (s_end \u003c sampleNum) ? s_end : sampleNum;\n      for (int s = s_start; s \u003c s_end; s++) {\n        float val = deepImage.image[depthChan][y][s];\n        ...\n      }\n    }\n  }\n\n```\n\n### deepview\n\n`examples/deepview` is simple deep image viewer in OpenGL. It can be tested with `deepscanline.exr`.\n\n![DeepViewExample](https://github.com/syoyo/tinyexr/blob/release/examples/deepview/deepview_screencast.gif?raw=true)\n\n## TinyEXR extension\n\n### ZFP\n\n#### NOTE\n\nTinyEXR adds ZFP compression as an experimemtal support (Linux and MacOSX only).\n\nZFP only supports FLOAT format pixel, and its image width and height must be the multiple of 4, since ZFP compresses pixels with 4x4 pixel block.\n\n#### Setup\n\nCheckout zfp repo as an submodule.\n\n    $ git submodule update --init\n\n#### Build\n\nThen build ZFP\n\n    $ cd deps/ZFP\n    $ mkdir -p lib   # Create `lib` directory if not exist\n    $ make\n\nSet `1` to `TINYEXT_USE_ZFP` define in `tinyexr.h`\n\nBuild your app with linking `deps/ZFP/lib/libzfp.a`\n\n#### ZFP attribute\n\nFor ZFP EXR image, the following attribute must exist in its EXR image.\n\n* `zfpCompressionType` (uchar).\n  * 0 = fixed rate compression\n  * 1 = precision based variable rate compression\n  * 2 = accuracy based variable rate compression\n\nAnd the one of following attributes must exist in EXR, depending on the `zfpCompressionType` value.\n\n* `zfpCompressionRate` (double)\n  * Specifies compression rate for fixed rate compression.\n* `zfpCompressionPrecision` (int32)\n  * Specifies the number of bits for precision based variable rate compression.\n* `zfpCompressionTolerance` (double)\n  * Specifies the tolerance value for accuracy based variable rate compression.\n\n#### Note on ZFP compression.\n\nAt least ZFP code itself works well on big endian machine.\n\n### Spectral EXR\n\nTinyEXR supports reading and writing spectral EXR files based on the JCGT 2021 paper:\nhttps://jcgt.org/published/0010/03/01/\n\nReference implementation: https://github.com/afichet/spectral-exr\n\n#### Spectrum Types\n\n| Type | Channel Format | Description |\n|------|----------------|-------------|\n| Emissive | `S{stokes}.{wavelength}nm` | Radiance/irradiance spectra (e.g., `S0.550,000000nm`) |\n| Reflective | `T.{wavelength}nm` | Transmittance/reflectance spectra (e.g., `T.550,000000nm`) |\n| Polarised | `S0-S3.{wavelength}nm` | Stokes vector spectra |\n\nWavelengths use European decimal convention (comma as separator).\n\n#### Spectral API Functions\n\n```cpp\n// Detection\nint IsSpectralEXR(const char* filename);\nint EXRGetSpectrumType(const EXRHeader* header);  // Returns TINYEXR_SPECTRUM_*\n\n// Channel naming\nvoid EXRSpectralChannelName(char* buffer, size_t size, float wavelength_nm, int stokes);\nvoid EXRReflectiveChannelName(char* buffer, size_t size, float wavelength_nm);\nfloat EXRParseSpectralChannelWavelength(const char* channel_name);\nint EXRGetStokesComponent(const char* channel_name);\n\n// Metadata\nint EXRSetSpectralAttributes(EXRHeader* header, int spectrum_type, const char* units);\nconst char* EXRGetSpectralUnits(const EXRHeader* header);\nint EXRGetWavelengths(const EXRHeader* header, float* wavelengths, int max);\n```\n\nSee `examples/spectral/` for a complete read/write example.\n\n## V3 API (Beta)\n\nTinyEXR V3 is a modern, production-quality C API with C++17 wrapper. It provides:\n\n- **Pure C11/C17 core**: No C++ dependencies in the C API\n- **C++17 wrapper**: RAII, `Result\u003cT\u003e`, range-based iteration\n- **Vulkan-style API**: Command buffers, fences, explicit synchronization\n- **Async/WASM-friendly**: Asyncify support, streaming I/O callbacks\n- **Exception-free**: Compatible with `-fno-exceptions -fno-rtti`\n\n### V3 Feature Comparison\n\n| Feature | V1 API | V3 API |\n|---------|--------|--------|\n| Error handling | Error codes + strings | `Result\u003cT\u003e` with error stack |\n| I/O model | Synchronous | Async with callbacks |\n| Threading | OpenMP | Command buffers, fences |\n| API style | Direct pointers | Opaque handles |\n| Memory | Manual | RAII (C++), explicit (C) |\n| Compression (read) | All except DWAA/DWAB | All except DWAA/DWAB |\n| Compression (write) | ZIP only | NONE, RLE, ZIP, ZIPS, PIZ, PXR24, B44 |\n| Deep images | Load only | Detection only (TODO) |\n\n### V3 Quick Example (C++)\n\n```cpp\n#include \"tinyexr_v3.hh\"\n\nusing namespace tinyexr::v3;\n\nauto ctx = Context::create().value;\nauto decoder = Decoder::from_file(ctx, \"input.exr\").value;\nauto image = decoder.parse_header().value;\n\nauto part = image.get_part(0).value;\nstd::cout \u003c\u003c \"Size: \" \u003c\u003c part.width() \u003c\u003c \"x\" \u003c\u003c part.height() \u003c\u003c \"\\n\";\n\n// Range-based tile iteration\nfor (auto tile : part.tiles(0)) {\n    // Load tile at (tile.tile_x, tile.tile_y)\n}\n```\n\n**See**: [TINYEXR_V3_README.md](TINYEXR_V3_README.md) for complete documentation.\n\n**Status**: Beta - suitable for evaluation and testing. V1 API remains stable for production use.\n\n## V2 API (Experimental)\n\nTinyEXR includes an experimental V2 API in separate header files that provides:\n\n- **Modern C++ interface**: `Result\u003cT\u003e` return types, `std::vector`-based data\n- **Enhanced error reporting**: Error stack with context, positions, and human-readable messages\n- **Header-only**: `tinyexr_v2.hh` + `tinyexr_v2_impl.hh`\n- **Safe memory access**: `StreamReader`/`StreamWriter` with bounds checking\n- **All compression formats**: Including PIZ, B44/B44A, PXR24 encoding\n\n### V2 Features\n\n| Feature | V1 API | V2 API |\n|---------|--------|--------|\n| Error handling | Error codes + strings | `Result\u003cT\u003e` with error stack |\n| Memory safety | Manual bounds checking | Automatic bounds checking |\n| Deep images | Load only | Load + Save (scanline \u0026 tiled) |\n| Spectral EXR | Full support | Full support |\n| Tiled writing | Basic | Full (mipmap/ripmap) |\n| Custom attributes | Basic | Full read/write API |\n\n### V2 Quick Example\n\n```cpp\n#include \"tinyexr_v2.hh\"\n#include \"tinyexr_v2_impl.hh\"\n\nusing namespace tinyexr::v2;\n\n// Load\nauto result = LoadFromFile(\"input.exr\");\nif (!result.success) {\n    printf(\"Error: %s\\n\", result.error_string().c_str());\n    return 1;\n}\nImageData\u0026 image = result.value;\n\n// Save\nauto save_result = SaveToFile(\"output.exr\", image);\n```\n\n**Note**: V2 API is experimental and subject to change. V1 API remains stable and recommended for production use.\n\n## Unit tests\n\nSee `test/unit` directory.\n\n## TODO\n\nContribution is welcome!\n\n- [ ] Compression\n  - [ ] B44?\n  - [ ] B44A?\n  - [ ] PIX24?\n- [ ] Custom attributes\n  - [x] Normal image (EXR 1.x)\n  - [ ] Deep image (EXR 2.x)\n- [ ] JavaScript library (experimental, using Emscripten)\n  - [x] LoadEXRFromMemory\n  - [ ] SaveMultiChannelEXR\n  - [ ] Deep image save/load\n- [ ] Write from/to memory buffer.\n  - [ ] Deep image save/load\n- [ ] Tile format.\n  - [x] Tile format with no LoD (load).\n  - [ ] Tile format with LoD (load).\n  - [ ] Tile format with no LoD (save).\n  - [ ] Tile format with LoD (save).\n- [ ] Support for custom compression type.\n  - [x] zfp compression (Not in OpenEXR spec, though)\n  - [ ] zstd?\n- [x] Multi-channel.\n- [ ] Multi-part (EXR2.0)\n  - [x] Load multi-part image\n  - [ ] Load multi-part deep image\n- [ ] Line order.\n  - [x] Increasing, decreasing (load)\n  - [ ] Random?\n  - [ ] Increasing, decreasing (save)\n- [ ] Pixel format (UINT, FLOAT).\n  - [x] UINT, FLOAT (load)\n  - [x] UINT, FLOAT (deep load)\n  - [x] UINT, FLOAT (save)\n  - [ ] UINT, FLOAT (deep save)\n- [ ] Support for big endian machine.\n  - [ ] Loading multi-part channel EXR\n  - [ ] Saving multi-part channel EXR\n  - [ ] Loading deep image\n  - [ ] Saving deep image\n- [ ] Optimization\n  - [ ] ISPC?\n  - [x] OpenMP multi-threading in EXR loading.\n  - [x] OpenMP multi-threading in EXR saving.\n  - [ ] OpenMP multi-threading in deep image loading.\n  - [ ] OpenMP multi-threading in deep image saving.\n\n## Python bindings\n\n`pytinyexr` is available: https://pypi.org/project/pytinyexr/ (loading only as of 0.9.1)\n\n## Similar or related projects\n\n* miniexr: https://github.com/aras-p/miniexr (Write OpenEXR)\n* stb_image_resize.h: https://github.com/nothings/stb (Good for HDR image resizing)\n\n## License\n\n3-clause BSD\n\n`tinyexr` uses miniz, which is developed by Rich Geldreich \u003crichgel99@gmail.com\u003e, and licensed under public domain.\n\n`tinyexr` tools uses stb, which is licensed under public domain: https://github.com/nothings/stb\n`tinyexr` uses some code from OpenEXR, which is licensed under 3-clause BSD license.\n`tinyexr` uses nanozlib and wuffs, whose are licensed unnder Apache 2.0 license.\n\n## Author(s)\n\nSyoyo Fujita (syoyo@lighttransport.com)\n\n## Contributor(s)\n\n* Matt Ebb (http://mattebb.com): deep image example. Thanks!\n* Matt Pharr (http://pharr.org/matt/): Testing tinyexr with OpenEXR(IlmImf). Thanks!\n* Andrew Bell (https://github.com/andrewfb) \u0026 Richard Eakin (https://github.com/richardeakin): Improving TinyEXR API. Thanks!\n* Mike Wong (https://github.com/mwkm): ZIPS compression support in loading. Thanks!\n","funding_links":["https://github.com/sponsors/syoyo"],"categories":["Libraries","Graphics"],"sub_categories":["C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyoyo%2Ftinyexr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyoyo%2Ftinyexr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyoyo%2Ftinyexr/lists"}