OpenImageIO Documentation

repository·main·Indexed 25 days ago

https://github.com/academysoftwarefoundation/openimageio

A professional-grade toolset for reading, writing, and manipulating image files in VFX and animation pipelines. It provides a format-agnostic API and a robust plugin system for various image formats (e.g., OpenEXR, TIFF, JPEG, PNG). Key features include the oiiotool command-line utility, ImageCache for TB-scale data management, TextureSystem for filtered MIP-map lookups, and Python bindings for its major APIs.

Tokens
162.3K
Snippets
271
Records
961
Agent score
77%

What's inside OpenImageIO

  1. Overview of OpenImageIO core APIs and components

    main

    OpenImageIO is an extensible image I/O library designed to abstract the reading and writing of 2D image file formats. It uses a plugin-based architecture where specific format support is implemented in dynamic libraries (DLLs, DSOs, etc.) loaded at runtime.

    Core Components

    • ImageInput & ImageOutput APIs: The primary interfaces for reading and writing image files. They are format-agnostic; the application interacts with the API, and the appropriate plugin handles the format details.
    • ImageBuf: A helper class for storing and manipulating images in memory. It uses ImageInput and ImageOutput for file operations and is compatible with the ImageBufAlgo namespace for common image processing operations.
    • ImageCache: A class that manages large amounts of image data (potentially terabytes) efficiently by using a small runtime memory footprint (megabytes to a few gigabytes).
    • TextureSystem: Provides filtered MIP-map texture lookups, built on top of ImageCache.
    • Utility Programs: Includes oiiotool (a command-line image processing engine) and iv (an image viewer).
  2. Overview of the `iconvert` utility

    main

    The iconvert program is a command-line utility used to convert images between different file formats supported by OpenImageIO. It reads an image using available ImageInput plugins and writes it using ImageOutput plugins.

    Beyond simple format conversion, iconvert can:

    • Change pixel data formats (e.g., floating-point to 8-bit integers).
    • Apply gamma correction.
    • Switch between tiled and scanline orientations.
    • Alter or add metadata (captions, keywords, IPTC tags).
    • Adjust file modification times to match image capture times.

    The output file format is automatically inferred from the file extension of the output filename.

  3. Overview of OpenImageIO core components

    main

    OpenImageIO (OIIO) is a toolset for reading, writing, and manipulating image files of any format relevant to VFX and animation using a format-agnostic API.

    Key components include:

    • ImageInput and ImageOutput APIs: High-level abstractions for reading and writing image files without needing to know specific format details. Implementation is handled via plugins loaded at runtime.
    • Plugin System: Manages format-specific I/O (e.g., TIFF, JPEG, OpenEXR, PNG, OpenVDB, etc.) as plug-ins.
    • Command Line Tools:
      • oiiotool: Format conversion and image processing.
      • iinfo: Prints detailed image information.
      • iconvert: Converts formats, data types, or modifies metadata.
      • idiff: Compares images.
      • igrep: Searches images for matching metadata.
      • iv: An image viewer.
    • ImageCache: Manages large amounts of image data (TB scale) efficiently using minimal runtime memory (MB scale).
    • TextureSystem: Provides filtered MIP-map texture lookups built on top of ImageCache.
    • ImageBuf and ImageBufAlgo: A class for in-memory image storage and a collection of image processing operations.
    • Python Bindings: Available for all major APIs.
  4. Overview of OpenImageIO

    main
    OpenImageIO (OIIO) is a library designed for reading, writing, and processing images across a wide variety of file formats using a format-agnostic API. It is specifically optimized for the formats and functionality required in professional, large-scale visual effects (VFX) and feature film animation workflows.
  5. OpenImageIO Licensing Information

    main

    OpenImageIO uses a dual-licensing model for its source code and a separate license for its documentation:

    Source Code

    • Apache 2.0 License: Applies to all new code contributed after July 1, 2023, and any code from prior to that date that has been relicensed under Apache-2.0.
    • BSD 3-clause License: Applies to a small portion (approximately 0.1%) of legacy code dating from prior to July 1, 2023, that has not been relicensed.

    Documentation

    • Creative Commons Attribution 4.0 International License (CC-BY-4.0): Applies to the OpenImageIO manual and all other text documentation.

    Third-Party Code

    OpenImageIO incorporates code from several other software packages with compatible licenses. A full list of these licenses is maintained in the THIRD-PARTY.md file.

  6. Understand the GPU texture system prototype architecture

    main

    This prototype implements a texture system designed for GPU-like kernel environments where host and device memory are treated as distinct. It uses a manager/managed architecture to handle texture lookups, missing-resource requests, and retry-based execution.

    Core Workflow

    1. Host Launch: The host launches a kernel on the device.
    2. Kernel Execution: The kernel performs lookups. If a texture or tile is missing, the kernel records a request.
    3. Host Resolution: The host detects missing resources via sync_from_managed(), resolves them (e.g., via a TextureLoader), and relaunches the kernel.
    4. Convergence: This loop repeats until all required data is resident.

    Memory Modes

    • non-unified (default): Host and device allocations are distinct; explicit copy_to and copy_from calls are required.
    • unified (--unified): Host and device may share the same underlying pointer, though the synchronization flow remains the same.
  7. What is ImageCache and when should I use it?

    main

    Overview

    ImageCache is a utility class designed for applications that need to read pixels from a large number of image files (potentially thousands of files totaling hundreds of GBs) while maintaining a very small memory footprint (e.g., ~50 MB).

    Key Advantages

    • Simplified Interface: You refer to images by filename only. You do not need to manually manage ImageInput objects, file handles, or explicit open/close operations.
    • Thread Safety: The class is completely thread-safe; it handles internal locking and resource sharing when multiple threads access the same file.
    • Automatic Resource Management:
      • File Handles: It maintains a reasonable number of simultaneously open files and automatically closes those not recently used.
      • Memory Management: It loads only requested tiles and automatically releases memory from tiles that haven't been used recently as memory limits are approached.
    • Granular Access: Supports retrieving blocks of pixels or locking/reading/releasing individual tiles.
  8. Introduction to ImageBuf

    main

    The ImageBuf class is a utility for storing and managing an entire image as a single unit. It provides a high-level API for reading, writing, and manipulating images without requiring the developer to manage low-level storage or I/O details.

    Under the hood, ImageBuf I/O operations (like read and write) utilize ImageCache, ImageInput, and ImageOutput, ensuring compatibility with all image file formats supported by OpenImageIO.

    To use ImageBuf, include the following header:

    #include <OpenImageIO/imagebuf.h>
  9. Manage SeedCorpus for fuzzing

    main

    The SeedCorpus consists of small, valid image files used to initialize the fuzzer. The implementation uses two distinct types of corpora:

    1. Committed Corpus: Located in src/fuzz/corpora/<format>/. This contains committed synthetic files for specific formats (e.g., dpx, fits, hdr, iff, jpeg2000, jpegxl, openexr, sgi).
    2. CI-time Corpus: Located in corpus/<format>/ within the runner workspace. For all other formats, the populate_corpora.py script pulls real-world seeds from the testsuite/ and companion repositories (like oiio-images or dicom-images-pvt) during the CI run. This avoids committing large binary files to the repository.

    Seed Corpus Requirements:

    • Files must be valid images parseable by OIIO for that specific format.
    • Total size should not exceed 5 MB per format to ensure fast loading.
    • Files must not contain copyrighted content (must be Apache-2.0 compatible).
  10. Use Region of Interest (ROI) with ImageBufAlgo

    main

    Most ImageBufAlgo functions accept an optional ROI (Region of Interest) parameter to restrict operations to a specific range of x, y, z, and channels.

    • Default Behavior: A default-constructed ROI (or ROI::All()) applies the operation to the entire image.
    • Writing to existing images: If the destination ImageBuf is already initialized, the operation only affects pixels within the ROI. Pixels outside the ROI remain unaltered.
    • Creating new images: If the function returns a new ImageBuf or the destination is uninitialized, the ROI determines the size of the resulting image. If ROI::All() is used, the result size is the union of the input images' pixel windows.
    • Channel restriction: The ROI respects chbegin and chend members, allowing you to restrict operations to specific color channels.