Post

Replies

Boosts

Views

Activity

SwiftUI raw image conversion
There seems to be a difference to the way iPadOS and macOS handle raw image files (tested with Fujifilm X-T3 uncompressed RAF file - included on the compatible list). Running the following code (with url set to the file location of the RAF file) on the iPad displays the preview jpeg embedded in the RAF file whereas on the mac the raw data are converted: AsyncImage(url: item.url) { phase in       if let image = phase.image {        image.resizable().aspectRatio(contentMode: .fit)       } else if phase.error != nil {        Color.red       } else {        Color.blue       }      } Am I missing something or is this the expected behaviour and is it documented somewhere?
2
0
1.2k
Dec ’21
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)")    }   }  } }
2
1
1.1k
Dec ’21