The OpenEXR API#
There are two separate, independent APIs for reading and writing EXR
image files: the traditional C++ API, and the newer C API, referred to
as OpenEXRCore. The C++ API is the original, widely-used interface
first released in 2003. It consists of the OpenEXR, Iex, and
IlmThread libraries, with functions and classes in the Imf::
namespace (or “image format”, the original the name of the library at
ILM prior to its public release).
The OpenEXRCore library, written primarily by Kimball Thurston at
Weta Digital, was introduced in July, 2021. This C-language
implementation of the file format is the result of a significant
re-thinking of image file I/O and access to image data. The
OpenEXRCore library provides thread-safe, non-blocking access to
files, which was not possible with the older C++ API, where the
framebuffer management is separate from read requests. This new
low-level API allows applications to do custom unpacking of EXR data,
such as on the GPU, while still benefiting from efficient I/O, file
validation, and other semantics. It provides efficient direct access
to EXR files in texturing applications. This C library also introduces
an easier path to implementing OpenEXR bindings in other languages,
such as Rust.
Currently, the two libraries and APIs sit alongside each other,
although in future OpenEXR releases, the C++ API will migrate to use
the new core in stages. It is not the intention to entirely deprecate
the C++ API, nor must all applications re-implement EXR I/O in terms
of the C library. The C API does not, and will not, provide the rich
set of utility classes that exist in the C++ layer. The
OpenEXRCore library simply offers new functionality for specialty
applications seeking the highest possible performance.
API
- Hello, World
- Reading and Writing Image Files with the OpenEXR Library
- Document Purpose and Audience
- Scan Line Based and Tiled OpenEXR files
- Using the RGBA-only Interface for Scan Line Based Files
- Using the General Interface for Scan Line Based Files
- Tiles, Levels and Level Modes
- Using the RGBA-only Interface for Tiled Files
- Using the General Interface for Tiled Files
- Deep Data Files
- Threads
- Low-Level I/O
- Miscellaneous
- Reading and Writing Image Files with the C-language API
- Simple Example
- Reading and Writing
- Data Types
- Chunks
- Encode and Decode
- Reference
- Basic Types
- Basic Enumerated Types
exr_compression_tEXR_COMPRESSION_NONEEXR_COMPRESSION_RLEEXR_COMPRESSION_ZIPSEXR_COMPRESSION_ZIPEXR_COMPRESSION_PIZEXR_COMPRESSION_PXR24EXR_COMPRESSION_B44EXR_COMPRESSION_B44AEXR_COMPRESSION_DWAAEXR_COMPRESSION_DWABEXR_COMPRESSION_HTJ2K256EXR_COMPRESSION_HTJ2K32EXR_COMPRESSION_LJ2KEXR_COMPRESSION_ZSTDEXR_COMPRESSION_LAST_TYPE
exr_envmap_texr_lineorder_texr_storage_texr_tile_level_mode_texr_tile_round_mode_texr_pixel_type_texr_attr_list_access_modeexr_perceptual_treatment_texr_default_write_mode
- Global State
- Chunk Reading
- Chunks
- Chunk Writing
- Open for Read
- Open for Write
- Close
- Context
- Decoding
_exr_decode_pipelinepipe_sizechannelsdecode_flagspart_indexuser_line_begin_skipuser_line_end_ignorebytes_decompresseddecoding_user_datapacked_bufferpacked_alloc_sizeunpacked_bufferunpacked_alloc_sizepacked_sample_count_tablesample_count_tablescratch_buffer_1scratch_alloc_size_1scratch_buffer_2scratch_alloc_size_2alloc_fnfree_fnread_fndecompress_fnrealloc_nonimage_data_fnunpack_and_convert_fn_quick_chan_storesample_count_validcompression_contextfree_compression_context
exr_decode_pipeline_texr_decoding_initialize()exr_decoding_choose_default_routines()exr_decoding_update()exr_decoding_run()exr_decoding_destroy()
- Encoding
exr_transcoding_pipeline_buffer_id_exr_encode_pipelinepipe_sizechannelsencode_flagspart_indexencoding_user_datapacked_bufferpacked_bytespacked_alloc_sizesample_count_tablesample_count_alloc_sizepacked_sample_count_tablepacked_sample_count_bytespacked_sample_count_alloc_sizecompressed_buffercompressed_bytescompressed_alloc_sizescratch_buffer_1scratch_alloc_size_1scratch_buffer_2scratch_alloc_size_2alloc_fnfree_fnconvert_and_pack_fncompress_fnyield_until_ready_fnwrite_fn_quick_chan_storeskip_sample_count_table_compression
exr_encode_pipeline_texr_coding_channel_info_texr_encoding_initialize()exr_encoding_choose_default_routines()exr_encoding_update()exr_encoding_run()exr_encoding_destroy()
- Attribute Values
exr_attr_chromaticities_texr_attr_keycode_texr_attribute_type_tEXR_ATTR_UNKNOWNEXR_ATTR_BOX2IEXR_ATTR_BOX2FEXR_ATTR_BYTESEXR_ATTR_CHLISTEXR_ATTR_CHROMATICITIESEXR_ATTR_COMPRESSIONEXR_ATTR_DOUBLEEXR_ATTR_ENVMAPEXR_ATTR_FLOATEXR_ATTR_FLOAT_VECTOREXR_ATTR_INTEXR_ATTR_KEYCODEEXR_ATTR_LINEORDEREXR_ATTR_M33FEXR_ATTR_M33DEXR_ATTR_M44FEXR_ATTR_M44DEXR_ATTR_PREVIEWEXR_ATTR_RATIONALEXR_ATTR_STRINGEXR_ATTR_STRING_VECTOREXR_ATTR_TILEDESCEXR_ATTR_TIMECODEEXR_ATTR_V2IEXR_ATTR_V2FEXR_ATTR_V2DEXR_ATTR_V3IEXR_ATTR_V3FEXR_ATTR_V3DEXR_ATTR_DEEP_IMAGE_STATEEXR_ATTR_OPAQUEEXR_ATTR_LAST_KNOWN_TYPE
exr_attribute_texr_attr_v2i_texr_attr_v2f_texr_attr_v2d_texr_attr_v3i_texr_attr_v3f_texr_attr_v3d_texr_attr_m33f_texr_attr_m33d_texr_attr_m44f_texr_attr_m44d_texr_attr_box2i_texr_attr_box2f_texr_attr_string_texr_attr_string_vector_texr_attr_float_vector_texr_attr_chlist_entry_texr_attr_chlist_texr_attr_preview_texr_attr_tiledesc_texr_attr_timecode_texr_attr_opaquedata_t
- Reading
exr_read_func_ptr_texr_query_size_func_ptr_texr_get_count()exr_get_name()exr_get_storage()exr_get_tile_levels()exr_get_tile_sizes()exr_get_level_sizes()exr_get_chunk_count()exr_get_scanlines_per_chunk()exr_get_chunk_unpacked_size()exr_get_attribute_count()exr_get_attribute_by_index()exr_get_attribute_by_name()exr_get_attribute_list()exr_attr_declare_by_type()exr_attr_declare()exr_initialize_required_attr()exr_initialize_required_attr_simple()exr_copy_unset_attributes()exr_get_channels()exr_get_compression()exr_get_data_window()exr_get_display_window()exr_get_lineorder()exr_get_pixel_aspect_ratio()exr_get_screen_window_center()exr_get_screen_window_width()exr_get_tile_descriptor()exr_get_version()exr_attr_get_box2i()exr_attr_get_box2f()exr_attr_get_channels()exr_attr_get_chromaticities()exr_attr_get_compression()exr_attr_get_double()exr_attr_get_envmap()exr_attr_get_float()exr_attr_get_float_vector()exr_attr_get_int()exr_attr_get_keycode()exr_attr_get_lineorder()exr_attr_get_m33f()exr_attr_get_m33d()exr_attr_get_m44f()exr_attr_get_m44d()exr_attr_get_preview()exr_attr_get_rational()exr_attr_get_string()exr_attr_get_string_vector()exr_attr_get_tiledesc()exr_attr_get_timecode()exr_attr_get_v2i()exr_attr_get_v2f()exr_attr_get_v2d()exr_attr_get_v3i()exr_attr_get_v3f()exr_attr_get_v3d()exr_attr_get_user()
- Writing
exr_write_func_ptr_texr_add_part()exr_add_channel()exr_set_channels()exr_set_compression()exr_set_data_window()exr_set_display_window()exr_set_lineorder()exr_set_pixel_aspect_ratio()exr_set_screen_window_center()exr_set_screen_window_width()exr_set_tile_descriptor()exr_set_name()exr_set_version()exr_set_chunk_count()exr_attr_set_box2i()exr_attr_set_box2f()exr_attr_set_channels()exr_attr_set_chromaticities()exr_attr_set_compression()exr_attr_set_double()exr_attr_set_envmap()exr_attr_set_float()exr_attr_set_float_vector()exr_attr_set_int()exr_attr_set_keycode()exr_attr_set_lineorder()exr_attr_set_m33f()exr_attr_set_m33d()exr_attr_set_m44f()exr_attr_set_m44d()exr_attr_set_preview()exr_attr_set_rational()exr_attr_set_string()exr_attr_set_string_vector()exr_attr_set_tiledesc()exr_attr_set_timecode()exr_attr_set_v2i()exr_attr_set_v2f()exr_attr_set_v2d()exr_attr_set_v3i()exr_attr_set_v3f()exr_attr_set_v3d()exr_attr_set_user()
- Error Handling
exr_error_code_tEXR_ERR_SUCCESSEXR_ERR_OUT_OF_MEMORYEXR_ERR_MISSING_CONTEXT_ARGEXR_ERR_INVALID_ARGUMENTEXR_ERR_ARGUMENT_OUT_OF_RANGEEXR_ERR_FILE_ACCESSEXR_ERR_FILE_BAD_HEADEREXR_ERR_NOT_OPEN_READEXR_ERR_NOT_OPEN_WRITEEXR_ERR_HEADER_NOT_WRITTENEXR_ERR_READ_IOEXR_ERR_WRITE_IOEXR_ERR_NAME_TOO_LONGEXR_ERR_MISSING_REQ_ATTREXR_ERR_INVALID_ATTREXR_ERR_NO_ATTR_BY_NAMEEXR_ERR_ATTR_TYPE_MISMATCHEXR_ERR_ATTR_SIZE_MISMATCHEXR_ERR_SCAN_TILE_MIXEDAPIEXR_ERR_TILE_SCAN_MIXEDAPIEXR_ERR_MODIFY_SIZE_CHANGEEXR_ERR_ALREADY_WROTE_ATTRSEXR_ERR_BAD_CHUNK_LEADEREXR_ERR_CORRUPT_CHUNKEXR_ERR_INCOMPLETE_CHUNK_TABLEEXR_ERR_INCORRECT_PARTEXR_ERR_INCORRECT_CHUNKEXR_ERR_USE_SCAN_DEEP_WRITEEXR_ERR_USE_TILE_DEEP_WRITEEXR_ERR_USE_SCAN_NONDEEP_WRITEEXR_ERR_USE_TILE_NONDEEP_WRITEEXR_ERR_INVALID_SAMPLE_DATAEXR_ERR_FEATURE_NOT_IMPLEMENTEDEXR_ERR_COMPRESSION_FAILEDEXR_ERR_DECOMPRESSION_FAILEDEXR_ERR_UNKNOWN
exr_error_handler_cb_texr_get_default_error_message()exr_get_error_code_as_string()
- Debugging