Quantcast
Channel: magick Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1011

Commented Unassigned: Canon specific EXIF values [1424]

$
0
0
When i use comand line exiftool to dump all of the metadata from this JPG i see two specific fields i really want to get. They are in a profile listed by exiftool as "Canon"

Time Zone : -05:00
Time Zone City : New York

When i'm using Magic.net if i get all of the available profiles for the JPG which i'm told are "exif" and "xmp" and loop through all available tags of both i don't see these tags or values and i've got no other tags that will give me the timezone. I'm attaching the JPG and the exiftool's dump file. I'd really love a way to be able to get those two values out otherwise i have no way to know which timezone the date/time fields i'm pulling from EXIF are in.


Comments: I'm not very proud of what i am trying. But after a lot of frustration it's where i am at. I normally read what i consider the creation date/time/zone out of IPTC. Photo that my system sees have it there pretty uniformly because some software post processed the photo and set those values. The photos i'm having this problem with are tethered so to speak. In reality they are actually submitting via FTP live from the field via a wifi hotspot from a phone. Just giving more information than you need in case it's interesting. These special photos that come to me straight from a Canon 1DX mk ii have no IPTC at all and i have no issue reading what i need except for this f^!%$&! timezone. So... what i did here in this hack was to extract the date and time from the EXIF's DateTimeOriginal field and extract the timezone from that specific field you found in Maker's note that is the offset in minutes. With those two values in hand i form them into a string that looks like what i am used to seeing from IPTC and then run the same code i use there to turn it into a .Net DateTime and DateTimeOffset, then get the timezone information from my database based on the offset. I need to do all of this none sense because we push out all of of our photos in UTC and we have to convert it to that properly from whatever it was on the way in. // if the date and time and time zone was not found in IPTC then try to get it out of the EXIF // this should only be the case on photos recieved via teathered cameras as all post processing // done in software provides us proper IPTC values if (!setDate) { // EpixTimeZoneManager.IncomingPhotoDateFormat:: "20170214 090332-0600" // Exif.DateTimeOriginal::"2017:02:07 13:32:34" try { var exifDate = exifProfile.GetValue(ExifTag.DateTimeOriginal); var markersNote = exifProfile.GetValue(ExifTag.MakerNote); if (exifDate != null) { string exifDateString = exifDate.Value.ToString(); int offsetMinutes = 0; if (markersNote != null) offsetMinutes = BitConverter.ToInt32((byte[])markersNote.Value, 2850); TimeSpan offsetTS = TimeSpan.FromMinutes(offsetMinutes); string dateTimeOffsetString = exifDateString.Substring(0, 4); dateTimeOffsetString += exifDateString.Substring(5, 2); dateTimeOffsetString += exifDateString.Substring(8, 2); dateTimeOffsetString += " "; dateTimeOffsetString += exifDateString.Substring(11, 2); dateTimeOffsetString += exifDateString.Substring(14, 2); dateTimeOffsetString += exifDateString.Substring(17, 2); if (offsetMinutes >= 0) dateTimeOffsetString += "+"; dateTimeOffsetString += offsetTS.Hours.ToString("00"); dateTimeOffsetString += offsetTS.Minutes.ToString("00"); DateTime dateCreated = DateTime.UtcNow; if (DateTime.TryParseExact(dateTimeOffsetString, EpixTimeZoneManager.IncomingPhotoDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated)) { metadataRecord.IPTCMetadata.DateCreated = dateCreated; } DateTimeOffset dateCreatedOffSet = DateTimeOffset.MinValue; if (DateTimeOffset.TryParseExact(dateTimeOffsetString, EpixTimeZoneManager.IncomingPhotoDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreatedOffSet)) { string dateCreatedTimeZone = EpixTimeZoneManager.GetTimeZoneBasedonOffset(offsetMinutes); if (!string.IsNullOrEmpty(dateCreatedTimeZone) && dateCreatedTimeZone.ToLower() != EpixTimeZoneManager.DefaultTimeZone.ToLower()) { metadataRecord.IPTCMetadata.DateCreatedTimeZone = dateCreatedTimeZone; metadataRecord.IPTCMetadata.DateCreatedOffsetMinutes = (double)offsetMinutes; } } } } catch (Exception exc) { logger.Warn(instanceLogFormatter.SetMessage("Error extracting creation time from EXIF: Exception: {0}", exc.Message).SetErrorLocation(exc.StackTrace, 0)); } }

Viewing all articles
Browse latest Browse all 1011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>