I am using ALAssetsLibrary to write an arbitrary UIImage to the the camera roll:
NSMutableDictionary exifAttachments = [[NSMutableDictionary alloc] init];
}
[exifAttachments setValue:[NSNumber numberWithInt:imgWidth] forKey:(NSString*)kCGImagePropertyExifPixelXDimension]; //OK
[exifAttachments setValue:[NSNumber numberWithInt:imgHeight] forKey:(NSString*)kCGImagePropertyExifPixelYDimension]; //OK
[exifAttachments setValue:[NSDate date] forKey:(NSString*)kCGImagePropertyExifDateTimeDigitized]; //NOT OK
_assetsLibrary writeImageToSavedPhotosAlbum:[img CGImage] metadata:exifAttachments completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"Big error: %@", [error description]);
}];
This works fine for some parameters, but all camera related parameters such as “time digitized”, “white balance”, etc. are just ignored.
Is there something wrong with my code? How can I manually add camera specific EXIF metadata?
[EDIT]
I found the solution myself. For all EXIF data a child-NSDictionary has to be added:
[exifAttachments setObject:[NSMutableDictionary dictionaryWithCapacity:1] forKey:(NSString*)kCGImagePropertyExifDictionary];
When adding data to this child then everything works fine.
Regards,
see edit above: