Extract raw + jpeg files from Photos

I have a SwiftUI application that processes image files from Fujifilm cameras - both raw and jpeg. When the image files are imported into the Photos app they are stacked so that you see only a single image when there are both raw and jpeg versions of the same image. Using Swift I cannot work out how to access both files - using the following code you get the jpeg file or the raw file if there is only a single file - but if there are both raw and jpeg files you only get the jpeg file.

import SwiftUI
import PhotosUI

struct PhotoPicker1: UIViewControllerRepresentable {
 typealias UIViewControllerType = PHPickerViewController
   
 @ObservedObject var mediaItems: PickedMediaItems
 var didFinishPicking: (_ didSelectItems: Bool) -> Void
   
 func makeUIViewController(context: Context) -> PHPickerViewController {
  var config = PHPickerConfiguration(photoLibrary: .shared())
  config.filter = .any(of: [.images])
  config.selectionLimit = 0
  config.preferredAssetRepresentationMode = .current
     
  let controller = PHPickerViewController(configuration: config)
  controller.delegate = context.coordinator
  return controller
 }
   
 func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) { }
   
 func makeCoordinator() -> Coordinator { Coordinator(with: self) }
   
 class Coordinator: PHPickerViewControllerDelegate {
  var photoPicker1: PhotoPicker1

  init(with photoPicker1: PhotoPicker1) {
   self.photoPicker1 = photoPicker1
  }
     
  func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
   photoPicker1.didFinishPicking(!results.isEmpty)
   guard !results.isEmpty else {
    return
   }
       
   for result in results {
    let itemProvider = result.itemProvider
    let typeIdentifier = itemProvider.registeredTypeIdentifiers.first ?? ""
    print("typeIdentifier: \(typeIdentifier)")
   }
  }
 }
}

@GreybeardUK did you find a solution to this? There is a type identifier UTTypeRAWImage which you can query on the item provider but it doesn't seem to work. Seems like a massive fail in PhotoKit.

No - all the information is there - its just very difficult to access using the tools Apple provides.

Extract raw + jpeg files from Photos
 
 
Q