Updating metadata properties of a DNG (or other) format image

Hi,

I'm looking to update the metadata properties of a DNG image stored on disc, saving to a new file.

Using ImageIO's CGImageSource and CGImageDestination classes, I run into a problem where by the destination doesn't support the type of the source. For example:

let imageSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary
			
if
	let cgImageSource = CGImageSourceCreateWithURL(sourceURL as CFURL, imageSourceOptions),
	let type = CGImageSourceGetType(cgImageSource) {
		guard let imageDestination = CGImageDestinationCreateWithURL(destinationURL as CFURL, type, 1, nil) else {
			fatalError("Unable to create image destination")
		}
						
		// Code to update properties and write out to destination url

	}
}

When this code is executed I get the following errors on the command line when trying to create the destination:

2024-06-30 11:52:25.531530+0100 ABC[7564:273101] [ABC] findWriterForTypeAndAlternateType:119: *** ERROR: unsupported output file format 'com.adobe.raw-image'
2024-06-30 11:52:25.531661+0100 ABC[7564:273101] [ABC] CGImageDestinationCreateWithURL:4429: *** ERROR: CGImageDestinationCreateWithURL: failed to create 'CGImageDestinationRef'

I don't see a way to create a destination directly from a source? Yes, the code works for say a JPEG file but I want it to work for any image format that CGImageSource can work with?

Updating metadata properties of a DNG (or other) format image
 
 
Q