Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to share an image via UIActivityViewController and retain exif data?

I have an app which saves images to a custom album within the camera roll via

    [library writeImageToSavedPhotosAlbum:[newTestImage CGImage] metadata:metadata
      completionBlock:^(NSURL *assetURL, NSError *error) {
        //error
      }
    ];

This works fine, however, I would then like to allow the user to share these images from within the app, I was doing it via

    ALAsset *assetToShare = self.images[indexPath.row];
        NSString *stringToShare = @"…..";
        NSArray *dataToShare = @[assetToShare, stringToShare];

        UIActivityViewController *activityVC = [[UIActivityViewController alloc]
              initWithActivityItems:dataToShare applicationActivities:nil];

        [self presentViewController:activityVC animated:YES completion: ^{
            //Some Expression  
        }];}

However in doing so the image is stripped of all exif data, is there a way I can implement the same functionality but retain the metadata? Thanks very much for any assistance.

Edit: Code used to enter ALAssets

    if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:@"my pics"]) {
                           [self.assetGroups addObject:group];
                           _displayArray = [self.assetGroups objectAtIndex:0]; ...}];

Then:

   [_displayArray enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
    if (result) {
        [self.images addObject:result]; }];
like image 372
peten Avatar asked Nov 13 '22 17:11

peten


1 Answers

Have you tried something like this? Just passing the actual image.

ALAsset *assetToShare = self.images[indexPath.row];

ALAssetRepresentation *rep = [assetToShare defaultRepresentation];

UIImage *imageToShare = [UIImage imageWithCGImage:[rep fullResolutionImage]];

NSString *stringToShare = @"…..";
NSArray *dataToShare = @[imageToShare, stringToShare];

UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:dataToShare applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion: ^{
//Some Expression
}];}
like image 146
brynbodayle Avatar answered Nov 17 '22 01:11

brynbodayle