Skip to content

Instantly share code, notes, and snippets.

@seanwolter
Last active December 11, 2015 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanwolter/4548690 to your computer and use it in GitHub Desktop.
Save seanwolter/4548690 to your computer and use it in GitHub Desktop.
EXIF handling methods in a photo model object
- (void)attachMetadata
{
DLog(@"EXIF data is %@",self.exifData);
[self.exifData setObject:@1 forKey:@"Orientation"];
NSData *jpeg = UIImageJPEGRepresentation(self.image, 1);
CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)jpeg, NULL);
NSMutableData *dest_data = [NSMutableData data];
CFStringRef UTI = CGImageSourceGetType(sourceRef);
CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)dest_data,UTI,1,NULL);
CGImageDestinationAddImageFromSource(destination,sourceRef,0, (__bridge CFDictionaryRef) self.exifData);
BOOL success = NO;
success = CGImageDestinationFinalize(destination);
if(success) {
[dest_data writeToFile:self.cFilePath atomically:YES];
} else {
DLog(@"***Could not create data from image destination ***");
}
CFRelease(destination);
CFRelease(sourceRef);
self.locationManager = nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment