Photos & Camera

RSS for tag

Explore technical aspects of capturing high-quality photos and videos, including exposure control, focus modes, and RAW capture options.

Post

Replies

Boosts

Views

Activity

Photos framework and reusable UICollectionViewCell
I have a UICollectionView to display photos from a device's album with the Photos framework. The photos are correctly displayed, but if I scroll fast (like when you tape at the top of the screen to go to the top of the collectionView), I have some photos which are not at the good indexPath. I just need to scroll a bit to put the bad photo out of the screen, and everything go back in place.I clean the cell during prepareForReuse by canceling the current request.I presume it's a problem with the asynchronous request of PHImageManager, but I don't know how to avoid this problem. And I want to keet the asynchronous request to keep the collectionView smooth.Here some code :View Controller extension AlbumDetailViewController : UICollectionViewDataSource { func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1 } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return photoList.count } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PhotoCell", forIndexPath: indexPath) as! PhotoCollectionCell cell.setImage(photoList.objectAtIndex(indexPath.row) as! PHAsset) return cell } }Custom CollectionViewCell class PhotoCollectionCell: UICollectionViewCell { @IBOutlet weak var imageView: UIImageView! var requestId: PHImageRequestID! let manager = PHImageManager.defaultManager() override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func prepareForReuse() { self.imageView.image = nil manager.cancelImageRequest(self.requestId) } func setImage(asset: PHAsset) { let option = PHImageRequestOptions() option.resizeMode = .Fast option.deliveryMode = .HighQualityFormat self.requestId = manager.requestImageForAsset(asset, targetSize: CGSize(width: self.frame.size.width * UIScreen.mainScreen().scale, height: self.frame.size.height * UIScreen.mainScreen().scale), contentMode: PHImageContentMode.Default, options: option, resultHandler: {(result, info)->Void in self.imageView.image = result }) } }Thank you
1
0
1.3k
Feb ’16
How to correctly load video selected with PHPickerViewController?
Hello! I am playing around with the PHPickerViewController and so far I was able to get the selected images by loading them into UIImage instances but I don't know how to get the selected video. Below is the relevant implementation of the method: func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]): let provider = result.itemProvider guard provider.hasItemConformingToTypeIdentifier(AVFileType.mov.rawValue) else { return } 						provider.loadItem(forTypeIdentifier: AVFileType.mov.rawValue, options: nil) { (fileURL, error) in 								if let error = error { 										print(error) 										return 								} 								guard let videoURL = fileURL as? URL else { return } 								DispatchQueue.main.async { 										let fm = FileManager.default 										let destination = fm.temporaryDirectory.appendingPathComponent("video123.mov") 										try! fm.copyItem(at: videoURL, to: destination) 										let playerVC = AVPlayerViewController() 										playerVC.player = AVPlayer(url: destination) 										self.present(playerVC, animated: true, completion: nil) 								} 						} I get crash trying to copy the item. It says the source file does not exists but the path looks real to me. "The file “3C2BCCBC-4474-491B-90C2-93DF848AADF5.mov” couldn’t be opened because there is no such file." I tried it without copying first and just passing the URL to AVPlayer but nothing would play. I am testing this on a simulator. Thanks for help!
13
0
7.4k
Jul ’20
Could not load some videos
Hello there! I am trying to use PHPickerViewController to load videos, but I got a problem: I could load some videos only not all. I refer to the existing thread - https://developer.apple.com/forums/thread/652695, but dosen't work. This is the code I persent PHPickerViewController var config = PHPickerConfiguration() config.selectionLimit = 1 config.filter = .videos config.preferredAssetRepresentationMode = .current let picker = PHPickerViewController(configuration: config) picker.delegate = self present(picker, animated: true, completion: nil) Below is the relevant implementation of the method: func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]): picker.dismiss(animated: true, completion: nil) for result in results {   result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { (url, error) in     if let error = error {       print(error)       return     }     guard let url = url else { return }     let fileName = "\(Date().timeIntervalSince1970).\(url.pathExtension)"     let newUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName)     try? FileManager.default.copyItem(at: url, to: newUrl)     DispatchQueue.main.async {       self.playVideo(newUrl)     }   } } Before I print error in line 5, Xcode printed 3 lines of error: [AXRuntimeCommon] Unknown client: TestPHPicker [default] [ERROR] Could not create a bookmark: NSError: Cocoa 257 "The file couldn’t be opened because you don’t have permission to view it." } Error copying file type public.movie. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.movie" UserInfo={NSLocalizedDescription=Cannot load representation of type public.movie, NSUnderlyingError=0x283a4a610 {Error Domain=NSCocoaErrorDomain Code=4101 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x283a48b10 {Error Domain=PHAssetExportRequestErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x283a4a550 {Error Domain=CloudPhotoLibraryErrorDomain Code=82 "Failed to download CPLResourceTypeOriginal" UserInfo=0x28219b300 (not displayed)}}}}}} And I print error in line 5: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.movie" UserInfo={NSLocalizedDescription=Cannot load representation of type public.movie, NSUnderlyingError=0x283a4a610 {Error Domain=NSCocoaErrorDomain Code=4101 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x283a48b10 {Error Domain=PHAssetExportRequestErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x283a4a550 {Error Domain=CloudPhotoLibraryErrorDomain Code=82 "Failed to download CPLResourceTypeOriginal" UserInfo=0x28219b300 (not displayed)}}}}}} For some videos I can load successfully, and some videos I got error. I don't know why this happened. I am testing this on an iPhone X iOS 14.0(18A373). Xcode 12.0 (12A7209). Thanks for help!
6
0
2.8k
Sep ’20
Ios flashlight specification
We are making application of ios. The application is for Disaster prevention in Japan. Because, Recentry in Japan has many Disaster in all season. We spplied to Local government in Japan and using general public and they are using well. One of the local government request to us, they want also supply to deaf person and help whe disaster occur. Local government already has disaster prevention broadcast but it is using loudspeaker. Then, when rains heavily, it can not hear to general public. And our application is from disaster prevention broadcast and forwarding to ios smartphone. It is helpfull to general public well. We are making new application it is not only prevention broadcast text but flashlight with iphone. But after making application, the flashlight is lighting only open our application. like beloe link. But, if Deaf person using it maybe he is not notice well. Our application is already has viblation function but Deaf person put his smartphone in his bag maybe I think he never noticed that Heavy rain and tsunami. Here is our application https://apps.apple.com/jp/app/cosmocast/id1247774270?mt=8 Here is application rule for flashlight. https://stackoverflow.com/questions/32136442/iphone-flashlight-not-working-while-app-is-in-background/32137434 I want help Deaf person and also senior citizens for Heavy rain and tsunami by our application. We'd like to make a flash light at the same time as the push notification arrived. Does anyone know a good way? Thank you and Best regards. Tomita.
1
0
655
Oct ’20
iOS 14 Photo caption - how to access in metadata??
I use the following code to parse Photo metadata and this works well. However, I am unable to pull the new iOS 14 "caption" from this metadata (it worked in early iOS 14 betas, but has since stopped working in the GM.) Does anyone know how I can get the caption data from a PHAsset? Thanks! Stephen         let options = PHContentEditingInputRequestOptions()         options.isNetworkAccessAllowed = true         asset.requestContentEditingInput(with: options, completionHandler: {(contentEditingInput, _) -> Void in             if let url = contentEditingInput?.fullSizeImageURL {                 let fullImage = CIImage(contentsOf: url)                                  // get all the metadata                 self.allPhotoMetadata = fullImage?.properties ?? [:]                                  // {TIFF}                 if let tiffDict = self.allPhotoMetadata["{TIFF}"] as? [String:Any] {                     if tiffDict["Make"] != nil {                         self.cameraData[cameraKeys.make] = tiffDict["Make"]                     }                     if tiffDict["Model"] != nil {                         self.cameraData[cameraKeys.model] = tiffDict["Model"]                     }                     if tiffDict["ImageDescription"] != nil {                         self.imageData[imageKeys.caption] = tiffDict["ImageDescription"]                     }                 }                                  // {IPTC}                 if let iptcDict = self.allPhotoMetadata["{IPTC}"] as? [String:Any] {                     // if we didn't find a caption in the TIFF dict, try to get it from IPTC data                     // first try, Caption/Abtract, then ArtworkContentDescription                     if self.imageData[imageKeys.caption] == nil {                         if iptcDict["Caption/Abstract"] != nil {                             self.imageData[imageKeys.caption] = iptcDict["ArtworkContentDescription"]                         } else if iptcDict["ArtworkContentDescription"] != nil {                             self.imageData[imageKeys.caption] = iptcDict["ArtworkContentDescription"]                         }                     }                 }             }         })     }
9
2
3.5k
Oct ’20
iPhone 13 / 13 mini builtInUltraWideCamera trouble
I ran into a strange problem. A camera app using AVFoundation, I use the following code; captureDevice = AVCaptureDevice.default(AVCaptureDevice.DeviceType.builtInUltraWideCamera, for: AVMediaType.video, position: .back) then, let isAutoFocusSupported = captureDevice.isFocusModeSupported(.autoFocus) "isAutoFocusSupported" should be "true". For iPhone 13 pro, it is "true". But for 13 / 13 mini, it is "false". Why?
4
0
1.6k
Oct ’21
iOS16: localIdentifier of PHAsset gets changed after saving to camera roll
Environment: iOS 16 beta 2, beta 3. iPhone 11 Pro, 12 mini Steps to reproduce: Subscribe to Photo Library changes via PHPhotoLibraryChangeObserver, put some logs to track inserted/deleted objects: func photoLibraryDidChange(_ changeInstance: PHChange) { if let changeDetails = changes.changeDetails(for: allPhotosFetchResult) { for insertion in changeDetails.insertedObjects { print("🥶 INSERTED: ", insertion.localIdentifier) } for deletion in changeDetails.removedObjects { print("🥶 DELETED: ", deletion.localIdentifier) } } } Save a photo to camera roll with PHAssetCreationRequest Go to the Photo Library, delete the newly saved photo Come back to the app and watch the logs: 🥶 INSERTED:  903933C3-7B83-4212-8DF1-37C2AD3A923D/L0/001 🥶 DELETED:  39F673E7-C5AC-422C-8BAA-1BF865120BBF/L0/001 Expected result: localIdentifier of the saved and deleted asset is the same string in both logs. In fact: It's different. So it appears that either the localIdentifier of an asset gets changed after successful saving, or it's a bug in the Photos framework in iOS 16. I've checked - in iOS 15 it works fine (IDs in logs match).
2
1
1.4k
Jul ’22
NSCocoaErrorDomain code = 134093 , only in iOS16
i have received a lot of crash log only in iOS16 the crash occured when i called : [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:resultHandler] here is the crash log Exception Type: NSInternalInconsistencyException ExtraInfo: Code Type: arm64 OS Version: iPhone OS 16.0 (20A5328h) Hardware Model: iPhone14,3 Launch Time: 2022-07-30 18:43:25 Date/Time: 2022-07-30 18:49:17 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:Unhandled error (NSCocoaErrorDomain, 134093) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134093 "(null)" Last Exception Backtrace: 0 CoreFoundation 0x00000001cf985dc4 0x1cf97c000 + 40388 1 libobjc.A.dylib 0x00000001c8ddfa68 0x1c8dc8000 + 96872 2 CoreData 0x00000001d56d2358 0x1d56cc000 + 25432 3 CoreData 0x00000001d56fa19c 0x1d56cc000 + 188828 4 CoreData 0x00000001d5755be4 0x1d56cc000 + 564196 5 CoreData 0x00000001d57b0508 0x1d56cc000 + 935176 6 PhotoLibraryServices 0x00000001df1783e0 0x1df0ed000 + 570336 7 Photos 0x00000001df8aa88c 0x1df85d000 + 317580 8 PhotoLibraryServices 0x00000001df291de0 0x1df0ed000 + 1723872 9 CoreData 0x00000001d574e518 0x1d56cc000 + 533784 10 libdispatch.dylib 0x00000001d51fc0fc 0x1d51f8000 + 16636 11 libdispatch.dylib 0x00000001d520b634 0x1d51f8000 + 79412 12 CoreData 0x00000001d574e0a0 0x1d56cc000 + 532640 13 PhotoLibraryServices 0x00000001df291d94 0x1df0ed000 + 1723796 14 PhotoLibraryServices 0x00000001df291434 0x1df0ed000 + 1721396 15 Photos 0x00000001df8a8380 0x1df85d000 + 308096 16 Photos 0x00000001df89d050 0x1df85d000 + 262224 17 Photos 0x00000001df87f62c 0x1df85d000 + 140844 18 Photos 0x00000001df87ee94 0x1df85d000 + 138900 19 Photos 0x00000001df87e594 0x1df85d000 + 136596 20 Photos 0x00000001df86b5c8 0x1df85d000 + 58824 21 Photos 0x00000001df86d938 0x1df85d000 + 67896 22 Photos 0x00000001dfa37a64 0x1df85d000 + 1944164 23 Photos 0x00000001dfa37d18 0x1df85d000 + 1944856 24 youavideo -[YouaImageManager requestImageDataForAsset:options:resultHandler:] (in youavideo) (YouaImageManager.m:0) 27 25 youavideo -[YouaAlbumTransDataController requstTransImageHandler:] (in youavideo) (YouaAlbumTransDataController.m:0) 27 26 youavideo -[YouaAlbumTransDataController requstTransWithHandler:] (in youavideo) (YouaAlbumTransDataController.m:77) 11 27 youavideo -[YouaUploadTransDataOperation startTrans] (in youavideo) (YouaUploadTransDataOperation.m:102) 19 28 Foundation 0x00000001c9e78038 0x1c9e3c000 + 245816 29 Foundation 0x00000001c9e7d704 0x1c9e3c000 + 268036 30 libdispatch.dylib 0x00000001d51fa5d4 0x1d51f8000 + 9684 31 libdispatch.dylib 0x00000001d51fc0fc 0x1d51f8000 + 16636 32 libdispatch.dylib 0x00000001d51ff58c 0x1d51f8000 + 30092 33 libdispatch.dylib 0x00000001d51febf4 0x1d51f8000 + 27636 34 libdispatch.dylib 0x00000001d520db2c 0x1d51f8000 + 88876 35 libdispatch.dylib 0x00000001d520e338 0x1d51f8000 + 90936 36 libsystem_pthread.dylib 0x00000002544b9dbc 0x2544b9000 + 3516 37 libsystem_pthread.dylib 0x00000002544b9b98 0x2544b9000 + 2968 i can't find the error code 134093 definition i don't know what's going wrong in iOS16 Would anyone have a hint of why this could happen and how to resolve it? thanks very much
7
5
2.7k
Aug ’22
PHPicker fails to load RAW images
We observed that the PHPicker is unable to load RAW images captured on an iPhone in some scenarios. And it is also somehow related to iCloud. Here is the setup: The PHPickerViewController is configured with preferredAssetRepresentationMode = .current to avoid transcoding. The image is loaded from the item provider like this: if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage) { itemProvider.loadFileRepresentation(forTypeIdentifier: kUTTypeImage) { url, error in // work } } This usually works, also for RAW images. However, when trying to load a RAW image that has just been captured with the iPhone, the loading fails with the following errors on the console: [claims] 43A5D3B2-84CD-488D-B9E4-19F9ED5F39EB grantAccessClaim reply is an error: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}} Error copying file type public.image. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.image" UserInfo={NSLocalizedDescription=Cannot load representation of type public.image, NSUnderlyingError=0x280480540 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}}}} We observed that on some devices, loading the image will actually work after a short time (~30 sec), but on others it will always fail. We think it is related to iCloud Photos: On the device that has iCloud Photos sync enabled, the picker is able to load the image right after it was synced to the cloud. On devices that don't sync the image, loading always fails. It seems that the sync process is doing some processing (?) of the image that will later enable the picker to load it successfully, but that's just guessing. Additional observations: This seems to only occur for images that were taken with the stock Camera app. When using Halide to capture RAW (either ProRAW or RAW), the Picker is able to load the image. When trying to load the image as kUTTypeRawImage instead of kUTTypeImage, it also fails. The picker also can't load RAW images that were AirDroped from another device, unless it synced to iCloud first. This is reproducable using the Selecting Photos and Videos in iOS sample code project. We observed this happening in other apps that use the PHPicker, not just ours. Is this a bug, or is there something that we are missing?
5
1
1.8k
Mar ’23
In iOS16,There was a crash when use [PHAssetCollection fetchAssetCollectionsWithType:subtype:options:]
On some iOS 16 mobile phones, it was found that there was a crash when using photo book to read the album. When the crash occurred, the console did not print any information. Through the xcodef stack, the crash occurred in the corresponding interface inside photo book, in the order of [PLPrivacy logPhotosAccessWithSelfAuditToken], -[PAAccessLogger log:], _ pthread_ wqthread, _ dispatch _ workloop_ worker_ thread, _ dispatch_ lane_ invoke, _ dispatch_ lane_ serial _ drain, _ dispatch _ client_ callout, _ dispatch_ block_ async invoke2, -[PAAccessLogger log:]_ block _ invoke, -[PACoalescingIntervalTracker coalesce:], _ dispatch_ source_ set_ runloop_ timer_ 4CF,
1
0
626
Mar ’23
{Error Domain=PHPhotosErrorDomain Code=3305 "(null)"}
When I used BOOL compatible = UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([pathUrl path]); if (compatible) { UISaveVideoAtPathToSavedPhotosAlbum([pathUrl path], self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil); } to save video,but here is some error. My phone has 33.72GB available and the video is only 4.2GB in size. What should i do? ps: I try to use [PHPhotoLibrary sharedPhotoLibrary] performChanges to save, but i got the same error. error code -3305.
2
1
2.6k
Apr ’23
AVAssetReader(asset: asset): The requested URL was not found on this server.
I'm trying the sample app from here: https://developer.apple.com/documentation/vision/detecting_moving_objects_in_a_video I made a tweak to read the video from library instead of document picker: var recordedVideoURL: AVAsset? @IBAction func uploadVideoForAnalysis(_ sender: Any) { var configuration = PHPickerConfiguration() configuration.filter = .videos configuration.selectionLimit = 1 let picker = PHPickerViewController(configuration: configuration) picker.delegate = self present(picker, animated: true, completion: nil) } The delegation method: extension HomeViewController: PHPickerViewControllerDelegate { func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { guard let selectedResult = results.first else { print("assetIdentifier: null") dismiss(animated: true, completion: nil) return } selectedResult.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { [weak self] url, error in guard error == nil, let url = url else { print(error?.localizedDescription ?? "Failed to load image") return } let asset = AVAsset(url: url) self?.recordedVideoURL = asset DispatchQueue.main.async { [weak self] in self?.dismiss(animated: true) { // dismiss the picker self?.performSegue(withIdentifier: ContentAnalysisViewController.segueDestinationId, sender: self!) self?.recordedVideoURL = nil } } } } } everything else is pretty much the same. Then, in the camera controller, it raised an error: "The requested URL was not found on this server." I put a debug break point and it show the error was from the line init AssetReader: let reader = AVAssetReader(asset: asset) func startReadingAsset(_ asset: AVAsset, reader: AVAssetReader? = nil) { videoRenderView = VideoRenderView(frame: view.bounds) setupVideoOutputView(videoRenderView) videoFileReadingQueue.async { [weak self] in do { guard let track = asset.tracks(withMediaType: .video).first else { throw AppError.videoReadingError(reason: "No video tracks found in the asset.") } let reader = AVAssetReader(asset: asset) let settings = [kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange] let output = AVAssetReaderTrackOutput(track: track, outputSettings: settings) if reader.canAdd(output) { reader.add(output) } else { throw AppError.videoReadingError(reason: "Couldn't add a track to the asset reader.") } if !reader.startReading() { throw AppError.videoReadingError(reason: "Couldn't start the asset reader.") } ... I tried to create a reader directly in the asset creation block, it worked: selectedResult.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { [weak self] url, error in guard error == nil, let url = url else { print(error?.localizedDescription ?? "Failed to load image") return } let asset = AVAsset(url: url) do { let reader = try AVAssetReader(asset: asset) self?.assetReader = reader print("reader: \(reader)") } catch let e { print("No reader: \(e)") } ... but if I just move it a little bit to the Dispatch.main.async block, it printed out "No reader: The requested URL was not found on this server. Therefore, I have to keep an instance of the reader and pass it to the cameraVC. Can someone please explain why is this happening? What's the logic behind this?
2
0
884
Jun ’23
Custom picker feature implementations
In the WWDC talk about the new embedded photo picker, the presenter says "If you want to implement your own replacement for some picker features, use the ".photosPicker DisabledCapabilities" modifier" (https://developer.apple.com/videos/play/wwdc2023/10107/?time=270). However, he did not demonstrate how to do so. For example, I want to use the compact version of the photo picker, with the header hidden, and place a custom "Add" button to use instead. Additionally, using any version of the picker, how could I add a button to the toolbar where "add" and "cancel" are? Is it possible to apply styling to the existing toolbar buttons, for instance changing the text color? Thanks!
1
0
789
Jun ’23
How to Set White Balance?
Here is a code snippet by which I attempted to set a neutral white balance: func prepare(completionHandler: @escaping (Error?) -> Void) { func createCaptureSession() { self.captureSession = AVCaptureSession() } func configureCaptureDevices() throws { let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back) let cameras = (session.devices.compactMap { $0 }) if cameras.isEmpty { throw CameraControllerError.noCamerasAvailable } for camera in cameras { try camera.lockForConfiguration() camera.setWhiteBalanceModeLocked( with whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains( redGain: 1.0, greenGain: 1.0, blueGain: 1.0), completionHandler handler: ((CMTime) -> Void)? = nil ) // Errors: Extra arguments at positions #2, #3 in call, Cannot find 'with' in scope camera.whiteBalanceMode = .locked camera.unlockForConfiguration() }catch{ // To Do: Error handling here } } My call to "AVCaptureDevice.WhiteBalanceGains()" gets errors. What is the correct way to do this?
0
0
571
Jun ’23
Loss of metadata when using deferred photo processing
We started implementing the new deferred photo processing and noticed a critical piece missing: It is not possible to set any custom metadata on the photo proxy before it has finished processing. The WWDC video mentions we as the developer need to update the photo later. In practice this proofs to be quite complicated to implement, because of the following reasons. It is not known when a photo will be processed Assuming the app is in the foreground it is still up to the operating system to decide when to process a photo There is no callback for when a photo is processed; only photo library changes that can be tracked when the app is in the foreground. Photo could be processed by the operating system when the app is on the background or not running at all. AVAsset has no public property available to indicate whether a photo is still waiting to be processed or is processed. Combined this requires complicated logic on the app side. The metadata needs to be cached on disk so that it can be added at a later stage and even if it is cached it is hard/impossible to match the cached metadata with a previously deferred photo. We filed FB12418208, we would love to see this fixed before iOS 17 comes out. I imagine that other camera app developers will have the same issue.
1
1
756
Jun ’23
Permissions when creating an album for an app and saving media
I am trying to create an album for an app in photo_kit and store images in it, is there any way to do this under the NSPhotoLibraryAddUsageDescription permission? At first glance, using NSPhotoLibraryAddUsageDescription seems to be the best choice for this app, since I will not be loading any images. However, there are two album operations that can only be done under NSPhotoLibraryUsageDescription. Creating an album Even though the creation of an album does not involve loading media, it is necessary to use NSPhotoLibraryUsageDescription to allow users to load media. This is a bit unconvincing. Saving images in the created album Before saving, you must check to see if the app has already created the album. You need to fetch the name as a key. This is where NSPhotLibraryUsageDescription is needed. I understand that the NSPhotLibraryUsageDescription is needed for fetching, but if iOS forbids the creation of albums with the same name and ignores attempts to create an album with an already existing name, this fetching will not be necessary. In summary, I just want to create an album for my app and store media in it, but in order to do so I need to get permission from the user to read into the photos, which goes against the idea that the permissions I request should be minimal and only what I need. If there is a way to do this under the NSPhotoLibraryAddUsageDescription permission I would like to know, I am new to Swift so sorry if I am wrong.
1
0
805
Jul ’23