Displaying HDR image, isn't showing dynamic range

I'm playing around with HDR images in iOS. I'm able to load an HDR image, but it isn't displaying with the expected "pop" I see of the same image in the Photos app. I exported the photo from Photos (on the Mac) using Export Unmodified. I reimported to confirm Photos shows the "pop."

I'm trying both UIImage and CIImage, with the same results. The below is tested on my iPhone 14 Pro (not Simulator).

The Storyboard for the code below has three UIImageViews (top, middle, and bottom).

let fileURL = Bundle.main.url(forResource: "IMG_6972", withExtension:"HEIC")!
var config = UIImageReader.Configuration()
config.prefersHighDynamicRange = true
let imageReader = UIImageReader(configuration: config)
let topImage = imageReader.image(contentsOf: fileURL)!
topImageView.preferredImageDynamicRange = .high
topImageView.image = topImage
// The image appears, looks SDR

print("topImage.isHighDynamicRange: \(topImage.isHighDynamicRange)") // true

let ciimage = CIImage(contentsOf: fileURL)!
bottomImageView.image = UIImage(ciImage: ciimage)
// The image appears, looks SDR - identical to topImage
print("color space: \(ciimage.colorSpace!)") // (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Display P3)

let gainMap = CIImage(contentsOf: fileURL, options: [.auxiliaryHDRGainMap: true])!
middleImageView.image = UIImage(ciImage: gainMap)
// The gain map image appears as expected

Additionally, for comparison, I tried:

let sdrImage = UIImage(named: "IMG_6972.HEIC")! // UIImage.named doesn't support HDR
print("sdrImage.isHighDynamicRange: \(sdrImage.isHighDynamicRange)")``` // false, as expected
bottomImageView.image = sdrImage

and the image matches the other two, further confirming the HDR version of the image isn't displaying in either UIImageReader or CIImage versions above.

I also track the UIScreen's use of EDR with:

print("currentEDR: \(UIScreen.main.currentEDRHeadroom)")
print("maxEDR: \(UIScreen.main.potentialEDRHeadroom)")

maxEDR is 8.0. currentEDR is 1.0 at launch, 1.3 after a 1.0 second delay. Which makes me think it might be showing a little HDR, but not enough to be noticeable.

Is there something special I need to do to set the UIViewController, UIScreen, or UIApplication (etc) to be an an "HDR Mode" or similar?

I think you've diagnosed the issue pretty well actually. The image likely just doesn't have very much HDR to display (in iOS 18 you can verify this more directly with some new API from Core Graphics – CGImageGetContentHeadroom) so there isn't much "pop".

In general the goal of HDR isn't necessarily to get more "pop" but more faithful representation of the content. It can mean deeper and more detailed shadows, just as much as brighter highlights. A lot of that will depend on how the images were themselves authored.

That said, there are bugs with UIKit's CoreImage support in iOS 17 that preclude it from properly showing HDR, otherwise a simple test would be putting brightness filter on the image which would boost it higher into the HDR range.

Displaying HDR image, isn't showing dynamic range
 
 
Q