Browse Source

fix date exif

marinofaggiana 3 years ago
parent
commit
d4c0518051

+ 7 - 5
iOSClient/Utility/CCUtility.m

@@ -1676,7 +1676,7 @@
     double latitude = 0;
     double longitude = 0;
     
-    NSDate *date = [NSDate new];
+    NSDate *date = nil;
     long fileSize = 0;
     int pixelY = 0;
     int pixelX = 0;
@@ -1697,7 +1697,7 @@
     CFDictionaryRef fileProperties = CGImageSourceCopyProperties(originalSource, nil);
     if (!fileProperties) {
         CFRelease(originalSource);
-        completition(latitude, longitude, location,date, lensModel);
+        completition(latitude, longitude, location, date, lensModel);
         return;
     }
     
@@ -1705,12 +1705,11 @@
     NSNumber *fileSizeNumber = CFDictionaryGetValue(fileProperties, kCGImagePropertyFileSize);
     fileSize = [fileSizeNumber longValue];
     
-    
     CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(originalSource, 0, NULL);
     if (!imageProperties) {
         CFRelease(originalSource);
         CFRelease(fileProperties);
-        completition(latitude, longitude, location,date, lensModel);
+        completition(latitude, longitude, location, date, lensModel);
         return;
     }
 
@@ -1725,6 +1724,10 @@
         NSString *sPixelY = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifPixelYDimension);
         pixelY = [sPixelY intValue];
         lensModel = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifLensModel);
+        dateTime = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifDateTimeOriginal);
+        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+        [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
+        date = [dateFormatter dateFromString:dateTime];
     }
  
     if (tiff) {
@@ -1733,7 +1736,6 @@
         NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
         [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
         date = [dateFormatter dateFromString:dateTime];
-        if (!date) date = metadata.date;
     }
     
     if (gps) {

+ 3 - 1
iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift

@@ -100,7 +100,6 @@ class NCViewerMediaDetailView: UIView {
         self.heightMap = heightMap
         self.image = image
         self.size = metadata.size
-        self.date = metadata.date
         
         if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue {
             CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensMode) in
@@ -134,6 +133,9 @@ class NCViewerMediaDetailView: UIView {
             
             dateLabel.text = NSLocalizedString("_date_", comment: "")
             dateValue.text = dateString
+        } else {
+            dateLabel.text = NSLocalizedString("_date_", comment: "")
+            dateValue.text = NSLocalizedString("_not_available_", comment: "")
         }
         
         // Dimension / Duration