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)")
}
}
}
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
I am developing a background application that acts as a metadata server under MacOS written in Swift. Sandboxed clients prompt the user to select URLs which are passed to the server as security scoped bookmarks via an App Group and the metadata will be passed back. I don't want the I/O overhead of passing the complete image file data to the server. All the variations I have tried of creating security scoped bookmarks in the client and reading them from the server fail with error messages such as "The file couldn’t be opened because it isn’t in the correct format." Can anyone guide me in the right direction or is this just not possible?
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
Files and Storage
App Sandbox
XPC