Write UIImage along with metadata (EXIF, GPS, TIFF) in iPhone's Photo library

后端 未结 8 1802
情歌与酒
情歌与酒 2020-11-29 05:12

I am developing a project, where the requirements are: - User will open the camera through the application - Upon capturing an Image, some data will be appended to the captu

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 05:17

    Getting meta data from cam captured image within an application:

    UIImage *pTakenImage= [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    
    NSMutableDictionary *imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:[info objectForKey:UIImagePickerControllerMediaMetadata]];
    

    now to save image to library with extracted metadata:

    ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
    [library writeImageToSavedPhotosAlbum:[sourceImage CGImage] metadata:imageMetadata completionBlock:Nil];
    [library release];
    

    or want to save to local directory

    CGImageDestinationAddImageFromSource(destinationPath,sourceImage,0, (CFDictionaryRef)imageMetadata);
    

提交回复
热议问题