Last active
December 11, 2015 04:58
-
-
Save seanwolter/4548690 to your computer and use it in GitHub Desktop.
EXIF handling methods in a photo model object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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