I'm trying to save a Portrait Mode photo on macOS (10.14.1) with embedded depth data.
The finalize function to write to a jpg file fails on macOS.
The following code works on iOS, but fails on macOS.
This will work on macOS if I comment out CGImageDestinationAddAuxiliaryDataInfo, so it appears to be the depth data.
guard let data = CFDataCreateMutable(kCFAllocatorDefault, 0) else {
// error
}
guard let cgImageDestination = CGImageDestinationCreateWithData(data, AVFileType.jpg as CFString, 1, nil) else {
// error
}
CGImageDestinationAddImage(cgImageDestination, cgImage, attachments)
//*******************************************************************
// add depth data - this section works on iOS but fails on macOS
var auxDataType :NSString?
let auxData = depthData.dictionaryRepresentation(forAuxiliaryDataType: &auxDataType)
let auxDataTemp = NSMutableDictionary(dictionary: auxData!)
CGImageDestinationAddAuxiliaryDataInfo(cgImageDestination, auxDataType!, auxDataTemp as CFDictionary)
//*******************************************************************
if CGImageDestinationFinalize(cgImageDestination) {
// success
return
} else {
// error ***************
print("Finalizing CGImageDestination error!")
return
}
Are the specs or requirements different on macOS for writing depth data?
Thanks,
James