Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced NSDates by UTC-formatted NSStrings for all date entries beca…

…use the standard NSDate format was not being parsed properly by many EXIF readers.
  • Loading branch information...
commit b3c8d501cfeeaac2a0d5cf1938554cf014a45e42 1 parent dd973eb
Elie Zananiri prisonerjohn authored
Showing with 19 additions and 4 deletions.
  1. +19 −4 GusUtils/NSMutableDictionary+ImageMetadata.m
23 GusUtils/NSMutableDictionary+ImageMetadata.m
View
@@ -22,6 +22,19 @@ @implementation NSMutableDictionary (ImageMetadataCategory)
@dynamic trueHeading;
+- (NSString *)getUTCFormattedDate:(NSDate *)localDate {
+
+ static NSDateFormatter *dateFormatter;
+ if (dateFormatter == nil) {
+ dateFormatter = [[NSDateFormatter alloc] init];
+ NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
+ [dateFormatter setTimeZone:timeZone];
+ [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
+ }
+ NSString *dateString = [dateFormatter stringFromDate:localDate];
+ return dateString;
+}
+
- (id)initWithImageSampleBuffer:(CMSampleBufferRef) imageDataSampleBuffer {
// Dictionary of metadata is here
@@ -112,7 +125,7 @@ - (void)setLocation:(CLLocation *)location {
if ([self objectForKey:(NSString*)kCGImagePropertyGPSDictionary]) {
[locDict addEntriesFromDictionary:[self objectForKey:(NSString*)kCGImagePropertyGPSDictionary]];
}
- [locDict setObject:location.timestamp forKey:(NSString*)kCGImagePropertyGPSTimeStamp];
+ [locDict setObject:[self getUTCFormattedDate:location.timestamp] forKey:(NSString*)kCGImagePropertyGPSTimeStamp];
[locDict setObject:latRef forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
[locDict setObject:[NSNumber numberWithFloat:exifLatitude] forKey:(NSString*)kCGImagePropertyGPSLatitude];
[locDict setObject:lngRef forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
@@ -205,12 +218,14 @@ - (void)setUserComment:(NSString*)comment {
}
- (void)setDateOriginal:(NSDate *)date {
- [EXIF_DICT setObject:date forKey:(NSString*)kCGImagePropertyExifDateTimeOriginal];
- [TIFF_DICT setObject:date forKey:(NSString*)kCGImagePropertyTIFFDateTime];
+ NSString *dateString = [self getUTCFormattedDate:date];
+ [EXIF_DICT setObject:dateString forKey:(NSString*)kCGImagePropertyExifDateTimeOriginal];
+ [TIFF_DICT setObject:dateString forKey:(NSString*)kCGImagePropertyTIFFDateTime];
}
- (void)setDateDigitized:(NSDate *)date {
- [EXIF_DICT setObject:date forKey:(NSString*)kCGImagePropertyExifDateTimeDigitized];
+ NSString *dateString = [self getUTCFormattedDate:date];
+ [EXIF_DICT setObject:dateString forKey:(NSString*)kCGImagePropertyExifDateTimeDigitized];
}
- (void)setMake:(NSString*)make model:(NSString*)model software:(NSString*)software {
Please sign in to comment.
Something went wrong with that request. Please try again.