5

I am trying to find out if reading OpenEXR files are supported or not on iOS and macOS.

Here is what I found out:

  1. The docs barely mention OpenEXR, and where they do they say that it's only supported on recent macOS.
  2. Yet, the official WWDC 2017 samples for ARKit simply load .exr images with:

    UIImage(named: "image.exr")
    

This is found in the following official samples:

  • Handling 3D Interaction and UI Controls in Augmented Reality
  • Interactive Content with ARKit
  • Audio in ARKit

How is OpenEXR support on iOS and on macOS?

hyperknot
  • 13,454
  • 24
  • 98
  • 153

1 Answers1

0

Apple has supported OpenEXR for a number of years through ImageIO / CGImageSource, and APIs like UIImage that layer over the top. As of 2-3 years ago, there was also added low level access in the form of libAppleEXR.dylib #include <AppleEXR.h>, which may be preferable if you need to monkey with metadata or deal with channel formats which do not map well to RGBA/XYZ/YCbCr. Apple made considerable improvements in this area to ImageIO for Ventura, so you'll have to decide if that is just fine. As Ventura is this week still quite new, likely you can't rely on it being installed everywhere. For cube maps, mipmaps, ripmaps and other more GPU-ish formats, you'll definitely want to use libAppleEXR.

The overall hierarchy these days is the heavy lifting is done by AppleEXR, ImageIO calls that, and CoreGraphics/AppKit/UIKit/vImage call ImageIO. Support is identical for MacOS/iOS/tvOS/watchOS.

Support for EXRs linear colorspaces was also improved in Ventura. Before that, the tone mapping is likely to just involve clipping if you don't draw to a extended range drawing surface.

If you actually want to use the OpenEXR library APIs from your app, you'll need to download the source and build that for your machine. ImageIO and libAppleEXR provide C-level programming interfaces and couldn't adopt OpenEXR's C++ interfaces for inclusion into a system library due to the usual C++ issues with stable ABI.

Ian Ollmann
  • 1,592
  • 9
  • 16
  • I will note that at last check, the open source EXR implementations were not vectorized for arm architectures such as Apples M-series desktop processors and all iOS / tvOS / watchOS devices. For this reason, where you can, it might be best to use the Apple one. Some fiddling may be required to realize the speed due to slowness in mmap vs read. – Ian Ollmann Apr 22 '23 at 15:14