photostructure / exiftool-vendored.js

Fast, cross-platform Node.js access to ExifTool
https://photostructure.github.io/exiftool-vendored.js/
MIT License
405 stars 37 forks source link

inferTimezoneFromDatestamps does not detect UTC/Z/+00:00 timezones #179

Closed stephanvane closed 2 months ago

stephanvane commented 2 months ago

Describe the bug When reading an xmp file, the timezone can succesfully be extracted using the following code:

await exiftool.read(path, undefined, { inferTimezoneFromDatestamps: true })

The result looks something like this:

{
  SourceFile: 'file.xmp',
  errors: [],
  tz: 'UTC+3',
  tzSource: 'CreationDate',
  ExifToolVersion: 12.82,
  ...

But when the timezone is UTC, we don't get this information:

{
  SourceFile: 'file.xmp',
  errors: [],
  ExifToolVersion: 12.82,
  ...

To Reproduce The files used to reproduce these results are:

returns UTC+3:

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.78'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:pdf='http://ns.adobe.com/pdf/1.3/'>
  <pdf:CreationDate>2021-12-21T02:35:00.000+03:00</pdf:CreationDate>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

returns nothing:

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.78'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:pdf='http://ns.adobe.com/pdf/1.3/'>
  <pdf:CreationDate>2021-12-21T00:35:00.000Z</pdf:CreationDate>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

Expected behavior I would expect that the second example would return:

{
  SourceFile: 'file.xmp',
  errors: [],
  tz: 'UTC',
  tzSource: 'CreationDate',
  ExifToolVersion: 12.82,
  ...

Environment (please complete the following information):

mceachen commented 2 months ago

This is actually behaving as expected: many popular smartphones and camera manufacturers erroneously mark non-time-zone-specific timestamps with a Z suffix (perhaps because the engineers didn’t know what Z meant?).

FWIW, if the timestamp uses an offset, it shouldn’t be ignored. And, more explicitly, you can set the timezoneOffset tag.

You’re also certainly free to wrap read() with your own code to add additional heuristics!