My photo extension app has access to both Camera and Photos. All is ok, but when pressing Done, it can not save image.
Code of standard completion handler:
- (void)finishContentEditingWithCompletionHandler:(void (^)(PHContentEditingOutput *))completionHandler {
// Update UI to reflect that editing has finished and output is being rendered.
// Render and provide output on a background queue.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:self.input];
NSError* error = nil;
NSData *renderedJPEGData = UIImageJPEGRepresentation(filtered_ui_image, 1.0);
assert(renderedJPEGData != nil);
//BOOL written_well = [renderedJPEGData writeToURL:output.renderedContentURL atomically:YES];
BOOL written_well = [renderedJPEGData writeToURL:output.renderedContentURL options:NSDataWritingAtomic error:&error];
assert(written_well);
// Call completion handler to commit edit to Photos.
completionHandler(output);
});
}
renderedJPEGData
is not nil
,error
is nil
, thus function [NSData writeToURL]
was successful, written_well
is YES
,
when debugging line-by-line, after block finishes, an alert appears:
output.renderedContentURL
is /private/var/mobile/Containers/Data/PluginKitPlugin/509C1A04-D414-4DB7-B1E6-83C47FC88BC9/tmp/blah_blah_name.JPG
So, I have permissions, debug shows no errors, what can I try to detect the cause of problem?
Check that the Google Photos app installed on your device is up-to-date. Some (read: older) versions of the app had bugs that prevented images from being edited and saved, particularly on SD cards. Google's new app updates are meant to fix these bugs. Visit the Google Photos page on the Play Store to update the app.
If your iPhone storage is full, you will meet photos not saving to camera roll on iPhone 13/12/SE or other iPhone models. You can go to Settings > General and choose iPhone Storage to check if your iPhone has enough storage. If not, you can delete some unimportant photos or other data to free up your iPhone storage.
One of the many reasons your screenshots and camera photos not saving to gallery Android is that there is an issue with the cache files of the Camera app. All you need do is to remove the app's cache files. Open the Settings app on your phone. Tap Apps & notifications, find Camera in the list, and tap it.
Tap Library, then tap All Photos or Days. Tap Select, then tap the thumbnails you want to copy. , then tap Copy. Paste the copies into another document.
As of iOS 10, the adjustment data must have at least one byte. This is a breaking change from iOS 9, where the adjustment data can be nil. I've tested this on both iOS 9 and iOS 10 to confirm.
Additional documentation: https://developer.apple.com/reference/photos/phcontenteditingoutput/1518684-adjustmentdata
PHContentEditingOutput* output = [[PHContentEditingOutput alloc] initWithContentEditingInput:self.input];
NSMutableData* adjustmentData = [NSMutableData data];
uint8_t byte = 1;
[adjustmentData appendBytes:&byte length:1];
output.adjustmentData = [[PHAdjustmentData alloc] initWithFormatIdentifier:@"com.yourcompany.yourapp" formatVersion:@"1.0f" data:adjustmentData];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With