Created
June 2, 2022 18:36
-
-
Save andsimakov/3d29305b0ab5d05dac3ed8092d4df92e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreImage | |
import CoreGraphics | |
import Foundation | |
extension CIImageRepresentationOption { | |
@available(iOS 14.1, macOS 11.0, macCatalyst 14.1, *) | |
static var hdrGainMapImage: Self { .init(rawValue: "kCIImageRepresentationHDRGainMapImage") } // not public, but should work | |
} | |
let image = CIImage(data: FileManager.default.contents(atPath: " /Users/miric/Downloads/hdr/IMG_1727.jpg")!)! // your input image | |
let gainMap = CIImage(data: FileManager.default.contents(atPath: "/Users/miric/Downloads/hdr/IMG_1727-hdrgainmap.jpg")!)! // your HDR gain map | |
let ciContext = CIContext() | |
let outputPath = URL(fileURLWithPath: "/Users/miric/Downloads/hdr/IMG_1727.heic") // path of the output image | |
try! ciContext.writeHEIFRepresentation(of: image, | |
to: outputPath, | |
format: .RGBA8, | |
colorSpace: CGColorSpace(name: CGColorSpace.displayP3)!, | |
options: [.hdrGainMapImage: gainMap]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still crashes: