Code Monkey home page Code Monkey logo

applejpeggainmap's People

Contributors

grapeot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

applejpeggainmap's Issues

Fail to execute the scprit

Mac mini M2 Sonoma 14.1.1, xcode 15.0.1 installed

hi, I tried your code, with provided sample pictures in thie repository, but i got errors as below, any ideas?

swift main.swift

JIT session error: Symbols not found: [ _NSDeviceWhiteColorSpace, OBJC_CLASS$_NSBitmapImageRep ]
Failed to materialize symbols: { (main, { _symbolic SDySSypG, _$sSo27NSBitmapImageRepPropertyKeyas35_HasCustomAnyHashableRepresentationSCMc, _got.$ss5UInt8VMn, _symbolic Say_____G s5UInt8V, _$sSays5UInt8VGMD, _$sSo16NSColorSpaceNameaMB, _$sS2iSZsWl, _$sSSSgWOh, _$s6AppKitMXM, _got.$sSHMp, _$sSo16NSColorSpaceNameaMF, _$sypSgWOh, _$sSDySSypGWOh, _$s4main25writeAuxiliaryDataToImage05inputF4Path07gainMapH00I4Meta0I11Description06outputfH0ySS_SSSo18CGImageMetadataRefaSDySSypGSStF, _$sypWOb, _$sSSSgWOc, _$sSo16NSBitmapImageRepC16bitmapDataPlanes10pixelsWide0G4High13bitsPerSample07samplesK5Pixel8hasAlpha8isPlanar14colorSpaceName05bytesK3Row0jkN0ABSgSpySpys5UInt8VGSgGSg_S4iS2bSo07NSColortU0aS2itcfC, _$sSays5UInt8VGSayxGSlsWl, _got.$ss35_HasCustomAnyHashableRepresentationP03_tobcD0s0cD0VSgyFTq, _main, _$sSSWOh, _symbolic SS_ypt, _$sSays5UInt8VGWOh, _$sSo27NSBitmapImageRepPropertyKeyaABSHSCWL, _$sSo12NSDictionaryCML, _$sSo27NSBitmapImageRepPropertyKeyaMF, _symbolic yp_ypt, _$sS2iSZsWL, _$sSo27NSBitmapImageRepPropertyKeyaMB, _$syp_yptMD, _associated conformance So27NSBitmapImageRepPropertyKeyas20_SwiftNewtypeWrapperSCSY, _$sSo27NSBitmapImageRepPropertyKeyaML, _$ss5Error_pMD, _$sSo27NSBitmapImageRepPropertyKeyaMf, _got.$ss11AnyHashableVMn, _got.$sSYMp, _$sSoMXM, _$sSDySSypGMD, _$sSo27NSBitmapImageRepPropertyKeyaMn, _$sSS_yptMD, _got.$sSQMp, _$ss11AnyHashableV_yptMD, _got.$sSHSQTb, _swift_FORCE_LOAD$swiftQuartzCore$_main, _swift_FORCE_LOAD$swiftMetal$_main, _symbolic $sSY, _symbolic SS, _associated conformance So16NSColorSpaceNameas20_SwiftNewtypeWrapperSCSY, _$sSays5UInt8VGSayxGSlsWL, _got.$ss12_ArrayBufferVMn, _$sSo27NSBitmapImageRepPropertyKeya_yptMD, _symbolic ______ypt s11AnyHashableV, _$sSo27NSBitmapImageRepPropertyKeyaABs20_SwiftNewtypeWrapperSCWL, _$ss12_ArrayBufferVys5UInt8VGAByxGSTsWL, _$ss12_ArrayBufferVys5UInt8VGMD, _$sS2Ss21_ObjectiveCBridgeable10FoundationWL, _$sSays5UInt8VGSayxGSTsWl, _$sSo16NSColorSpaceNameaABSHSCWL, _$sSays5UInt8VGSayxGSTsWL, _$sSo16NSColorSpaceNameaSYSCSY8rawValue03RawE0QzvgTW, _$sSo27NSBitmapImageRepPropertyKeyaSHSCSH4hash4intoys6HasherVz_tFTW, _swift_FORCE_LOAD$swiftDarwin$_main, _$sSo16NSColorSpaceNameaSYSCSY8rawValuexSg03RawE0Qz_tcfCTW, _swift_FORCE_LOAD$swiftCoreFoundation$_main, _symbolic ______p s5ErrorP, _got.$sSY8rawValue03RawB0QzvgTq, _$s4main20imageDataFromCGImage7cgImage10Foundation0C0VSgSo0E3Refa_tF, _$sSo11CFStringRefaMf, $s10Foundation4DataV5write2to7optionsyAA3URLV_So20NSDataWritingOptionsVtKFfA0, _$sSo11CFStringRefaMn, _swift_FORCE_LOAD$swiftCoreGraphics$_main, _$sSo27NSBitmapImageRepPropertyKeya8rawValueABSS_tcfC, _$sSo16NSColorSpaceNameaABSQSCWL, _$sSo11CFStringRefaML, _$sSo27NSBitmapImageRepPropertyKeyaSYSCMA, _$sSo27NSBitmapImageRepPropertyKeyaSHSCSH9hashValueSivgTW, _$sSo27NSBitmapImageRepPropertyKeyaSYSCSY8rawValue03RawG0QzvgTW, _$sSo27NSBitmapImageRepPropertyKeyaSYSCMc, _$sSo18CGImageMetadataRefaMn, _got.$sSY8rawValuexSg03RawB0Qz_tcfCTq, _got.$ss35_HasCustomAnyHashableRepresentationMp, _$sSo27NSBitmapImageRepPropertyKeyaSQSCSQ2eeoiySbx_xtFZTW, _$sS2is17FixedWidthIntegersWL, _swift_FORCE_LOAD$swiftOSLog$_main, _$sSo16NSBitmapImageRepCML, _swift_FORCE_LOAD$swiftCoreImage$_main, _$ss5Int32VABSzsWL, _swift_FORCE_LOAD$swiftos$_main, _swift_FORCE_LOAD$swiftFoundation$_main, _swift_FORCE_LOAD$swiftIOKit$_main, _swift_FORCE_LOAD$swiftXPC$_main, _swift_FORCE_LOAD$swiftDispatch$_main, _got.$ss5ErrorMp, _swift_FORCE_LOAD$swiftObjectiveC$_main, _got.$s15_ObjectiveCTypes01_A11CBridgeablePTl, _$sSo27NSBitmapImageRepPropertyKeyas21_ObjectiveCBridgeableSCMA, _$sSo27NSBitmapImageRepPropertyKeyaABSQSCWL, _symbolic _____ So27NSBitmapImageRepPropertyKeya, _symbolic $ss21_ObjectiveCBridgeableP, _$sSo27NSBitmapImageRepPropertyKeyas21_ObjectiveCBridgeableSCMc, _got.$ss21_ObjectiveCBridgeableMp, _$sSo27NSBitmapImageRepPropertyKeyaSHSCSH13_rawHashValue4seedS2i_tFTW, _got.$ss21_ObjectiveCBridgeableP09_bridgeToA1C01_A5CTypeQzyFTq, _$s4main15gainDescriptionSDySSypGSgvp, _symbolic _____ So16NSColorSpaceNamea, _$sSo16NSColorSpaceNameas21_ObjectiveCBridgeableSCMA, _$s4main18outputHDRImagePathSSvp, _$sSo16NSColorSpaceNameaSYSCMA, _$sSo16NSBitmapImageRepC16bitmapDataPlanes10pixelsWide0G4High13bitsPerSample07samplesK5Pixel8hasAlpha8isPlanar14colorSpaceName05bytesK3Row0jkN0ABSgSpySpys5UInt8VGSgGSg_S4iS2bSo07NSColortU0aS2itcfcTO, _$sSo16NSColorSpaceNameas21_ObjectiveCBridgeableSCMc, _$s4main8gainMetaSo18CGImageMetadataRefaSgvp, _$sSo27NSBitmapImageRepPropertyKeyaABSYSCWL, _$sSo18CGImageMetadataRefaMf, _$sSo27NSBitmapImageRepPropertyKeyaSQSCMc, _$sSo16NSColorSpaceNameaABs20_SwiftNewtypeWrapperSCWl, _got.$ss20_SwiftNewtypeWrapperMp, $.main.__inits.0, ___swift_instantiateConcreteTypeFromMangledNameAbstract, _got.$ss20_SwiftNewtypeWrapperPSYTb, _$sSDySSypGSDyxq_Gs21_ObjectiveCBridgeable10FoundationWl, _$sSo18CGImageMetadataRefaML, _$sSo27NSBitmapImageRepPropertyKeyaSHSCMc, _$sSo27NSBitmapImageRepPropertyKeya8rawValueSSvg, _$sSo16NSColorSpaceNameaABSYSCWL, _$sSo16NSColorSpaceNameaSHSCSH13_rawHashValue4seedS2i_tFTW, _got.$sSH4hash4intoys6HasherVz_tFTq, _got.$sSH13_rawHashValue4seedS2i_tFTq, _$sSo16NSColorSpaceNameaSHSCSH4hash4intoys6HasherVz_tFTW, _$sSo16NSColorSpaceNameaABSHSCWl, _$s4main12sdrImagePathSSvp, _$sSo27NSBitmapImageRepPropertyKeyaABSHSCWl, _$sSo18CGImageMetadataRefaMa, ___swift_instantiateConcreteTypeFromMangledName, _$sS2Ss21_ObjectiveCBridgeable10FoundationWl, _symbolic ______ypt So27NSBitmapImageRepPropertyKeya, _$ss5Int32VABSzsWl, _$sSo16NSColorSpaceNameaSQSCSQ2eeoiySbx_xtFZTW, _$sS2is17FixedWidthIntegersWl, _symbolic _____y_____G s12_ArrayBufferV s5UInt8V, _$sSo16NSBitmapImageRepCMa, _got.$sSH9hashValueSivgTq, _$sSo16NSColorSpaceNameaABs20_SwiftNewtypeWrapperSCWL, _$ss12_ArrayBufferVys5UInt8VGAByxGSTsWl, _associated conformance So16NSColorSpaceNameas20_SwiftNewtypeWrapperSCs35_HasCustomAnyHashableRepresentation, _$sSDySSypGSDyxq_Gs21_ObjectiveCBridgeable10FoundationWL, _$s12CoreGraphics7CGFloatVyACxcSzRzlufCSi_Tgq5, $sSo12CGContextRefa12CoreGraphicsE4draw_2in8byTilingySo07CGImageB0a_So6CGRectVSbtFfA1, _$s4main18referenceImagePathSSvp, _swift_FORCE_LOAD$swiftUniformTypeIdentifiers$_main, ___swift_project_boxed_opaque_existential_0, _$sSo27NSBitmapImageRepPropertyKeyas20_SwiftNewtypeWrapperSCMc, _$s10Foundation4DataV15_RepresentationOWOy, _got.$sSQ2eeoiySbx_xtFZTq, _$sSo27NSBitmapImageRepPropertyKeyas35_HasCustomAnyHashableRepresentationSCsACP03_toghI0s0hI0VSgyFTW, _associated conformance So16NSColorSpaceNameaSHSCSQ, _associated conformance So27NSBitmapImageRepPropertyKeyaSHSCSQ, ___swift_destroy_boxed_opaque_existential_0, _$ss26DefaultStringInterpolationVWOh, _symbolic So8NSStringC, _$sSo16NSColorSpaceNameas20_SwiftNewtypeWrapperSCMc, _$s4main16gainMapImagePathSSvp, _$s10Foundation4DataV15_RepresentationOWOe, _$sSo16NSColorSpaceNamea8rawValueABSS_tcfC, _$sSo16NSColorSpaceNameas21_ObjectiveCBridgeableSCsACP026_unconditionallyBridgeFromD1Cyx01_D5CTypeQzSgFZTW, _$sSo27NSBitmapImageRepPropertyKeyaABSYSCWl, _$sSo16NSColorSpaceNameaABSQSCWl, _$sSo16NSColorSpaceNamea8rawValueSSvg, _$sSo27NSBitmapImageRepPropertyKeyaABSQSCWl, _$sSo16CGImageAlphaInfoV8rawValues6UInt32Vvg, _$sSo16NSColorSpaceNameas21_ObjectiveCBridgeableSCsACP016_forceBridgeFromD1C_6resulty01_D5CTypeQz_xSgztFZTW, _$sSo16NSColorSpaceNameaABSYSCWl, _$sSo16NSColorSpaceNameaABs35_HasCustomAnyHashableRepresentationSCWL, _$sSo27NSBitmapImageRepPropertyKeyaMa, _$sSo16NSColorSpaceNameaSHSCSH9hashValueSivgTW, _$sSo11CFStringRefaMa, _$sSo12NSDictionaryCMa, _$sSa12_endMutationyyF, _$sSo27NSBitmapImageRepPropertyKeyaABs35_HasCustomAnyHashableRepresentationSCWL, _$s4main14extractGainMap13inputFilePath06outputfG0So18CGImageMetadataRefaSg_SDySSypGSgtSS_SSSgtF, _got.$ss21_ObjectiveCBridgeableP024_conditionallyBridgeFromA1C_6resultSb01_A5CTypeQz_xSgztFZTq, _$sSo27NSBitmapImageRepPropertyKeyas21_ObjectiveCBridgeableSCsACP026_unconditionallyBridgeFromF1Cyx01_F5CTypeQzSgFZTW, _got.$ss21_ObjectiveCBridgeableP016_forceBridgeFromA1C_6resulty01_A5CTypeQz_xSgztFZTq, _$sSo27NSBitmapImageRepPropertyKeyas21_ObjectiveCBridgeableSCsACP024_conditionallyBridgeFromF1C_6resultSb01_F5CTypeQz_xSgztFZTW, _$sSo16NSColorSpaceNameaABs35_HasCustomAnyHashableRepresentationSCWl, $ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lFSbyXEfu_SbyKXEfu0, _$sSo27NSBitmapImageRepPropertyKeyas21_ObjectiveCBridgeableSCsACP016_forceBridgeFromF1C_6resulty01_F5CTypeQz_xSgztFZTW, $ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lFSbyXEfu, _got.$ss21_ObjectiveCBridgeableP026_unconditionallyBridgeFromA1Cyx01_A5CTypeQzSgFZTq, _$sSo16NSColorSpaceNameas21_ObjectiveCBridgeableSCsACP024_conditionallyBridgeFromD1C_6resultSb01_D5CTypeQz_xSgztFZTW, _$ss27_finalizeUninitializedArrayySayxGABnlF, _$sSo27NSBitmapImageRepPropertyKeyaABs20_SwiftNewtypeWrapperSCWl, $ss5print_9separator10terminatoryypd_S2StFfA0, $ss5print_9separator10terminatoryypd_S2StFfA1, _$sSo27NSBitmapImageRepPropertyKeyaSYSCSY8rawValuexSg03RawG0Qz_tcfCTW, _$sSo27NSBitmapImageRepPropertyKeyaABs35_HasCustomAnyHashableRepresentationSCWl, _got.$ss20_SwiftNewtypeWrapperPs35_HasCustomAnyHashableRepresentationTb, _$sSo16NSColorSpaceNameaMf, _$sSo16NSColorSpaceNameas21_ObjectiveCBridgeableSCsACP09_bridgeToD1C01_D5CTypeQzyFTW, _$sSo16NSColorSpaceNameaSHSCMc, _$sSo16NSColorSpaceNameaML, _$sSo16NSColorSpaceNameas35_HasCustomAnyHashableRepresentationSCsACP03_toefG0s0fG0VSgyFTW, _$sSo16NSColorSpaceNameaSYSCMc, _$sSo16NSColorSpaceNameaMa, _$sSo16NSColorSpaceNameaSQSCMc, _$sSo27NSBitmapImageRepPropertyKeyas21_ObjectiveCBridgeableSCsACP09_bridgeToF1C01_F5CTypeQzyFTW, _$sSo16NSColorSpaceNameas35_HasCustomAnyHashableRepresentationSCMc, _$sSo16NSColorSpaceNameaMn, _associated conformance So27NSBitmapImageRepPropertyKeyas20_SwiftNewtypeWrapperSCs35_HasCustomAnyHashableRepresentation, _got.$s8RawValueSYTl }) }

Gain Map orientation

Hi, I probably encountered a problem in generating HDR gain maps for Apple: I'm not a programmer, just a computer and photography enthusiast. First, I'll describe how I'm using your tool.

Initially, probably because I'm not a programmer, I couldn't find a way to generate an HDR gain map from various ProRaw files recently made with my iPhone 15 Pro Max. So I "unpacked" your Swift code into two files so that in one there is only the "generation" mechanism (to obtain the gain map in PNG format from the DNG file) and in one the original script (to obtain the final file from PNG map and SDR image version in HEIC): in this (clumsy and inconvenient) way, running one script at a time, I manage to generate many files that work beautifully.

If I took a DNG photo with my iPhone in portrait orientation, Lightroom's DNG and HEIC file works perfectly, and the Exif data reports both 90° CW and 270 rotation orientation. Unfortunately, the PNG gain map is made in a different orientation, something "90 degrees counterclockwise" compared to the actual photo.

how to generate gain_map.png

Can you explain how the gain_map.png in the project is generated?
I use other grayscale PNG images, and CGImageDestinationFinalize fails.

Perhaps a simpler approach to make an iOS-compatible HDR image

Hello, I was trying to generate an iOS-compatible image from my Lightroom and bump into this repository.

Correct me if I'm wrong, but I think this repository mainly focus on how to generate iOS-compatible image from ISO hdr images generated from softwares like adobe? Well if that's the case here, another repo https://github.com/HCYANG2000/Generate_Apple_HDR_Photos might be a somehow simpler approach to do so.

I tested it on my mac and iPhone and it works great on converting Adobe Lightroom generated avifs with HDR effect to iOS-compatible heic.

here's my modified code that compiles and works as swift main.swift ./path-to-avif

import Cocoa
import CoreImage

// Constants for command line arguments
struct CommandLineArguments {
    let path: String
    let compressionRatio: CGFloat
}

// Parses the command line arguments and returns a struct
func parseCommandLineArguments() -> CommandLineArguments {
    let arguments = CommandLine.arguments
    let path = arguments.count > 1 ? arguments[1] : "."
    let compressionRatio = arguments.count > 2 ? CGFloat(Double(arguments[2]) ?? 0.7) : 0.7
    
    return CommandLineArguments(
        path: path,
        compressionRatio: compressionRatio
    )
}

// Function to check if the path is a directory and process accordingly
func processPath(_ path: String, compressionRatio: CGFloat) {
    let fileManager = FileManager.default
    var isDirectory: ObjCBool = false

    let imageExtensions = [".avif"]

    if fileManager.fileExists(atPath: path, isDirectory: &isDirectory) {
        if isDirectory.boolValue {
            // It's a directory, process all non-heic files
            do {
                let files = try fileManager.contentsOfDirectory(atPath: path)
                for file in files {
                    let filePath = (path as NSString).appendingPathComponent(file)
                    if imageExtensions.contains(where: file.hasSuffix) {
                        processFile(filePath, compressionRatio: compressionRatio)
                    }
                }
            } catch {
                print("Error reading contents of directory: \(error)")
            }
        } else {
            // It's a file, process the single file
            processFile(path, compressionRatio: compressionRatio)
        }
    } else {
        print("The provided path does not exist.")
    }
}

// Function to process a single file
func processFile(_ filePath: String, compressionRatio: CGFloat) {
    guard let colorSpace = CGColorSpace(name: CGColorSpace.itur_2100_HLG) else {
        print("Couldn't create a color space.")
        exit(1)
    }
    let context = CIContext(options: [.workingColorSpace: colorSpace])

    let inputURL = URL(fileURLWithPath: filePath)
    let outputURL = inputURL.deletingPathExtension().appendingPathExtension("heic")

    print(inputURL.path, " -> ", outputURL.path)

    guard let image = CIImage(contentsOf: inputURL, options: [.expandToHDR: true]) else {
        print("Couldn't create an image from \(inputURL.path).")
        exit(1)
    }

    let options = [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption: compressionRatio]
    do {
        try context.writeHEIF10Representation(of: image, to: outputURL, colorSpace: image.colorSpace!, options: options)
    } catch {
        print("Failed to write the image with error: \(error)")
        exit(1)
    }
}

// Main function to execute the conversion process
func main() {
    let args = parseCommandLineArguments()
    
    guard !args.path.isEmpty else {
        print("Usage: <path> [compressionRatio]")
        return
    }
    
    processPath(args.path, compressionRatio: args.compressionRatio)
}

// Run the main function
main()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.