Warning: Month 'NN' out of range 1..12 in ExifIFD:DateTimeOriginal

Started by chono, November 06, 2021, 06:37:22 PM

Previous topic - Next topic

chono

First time user -- so this is likely a user error and not a real bug.
I'm working on converting a Google Takeout dataset.

Many (all?) of my files give the Month 'NN' out of range warning (and then don't update the original / photo taken date in the exif)


>~/bin/Image-ExifTool-12.34/exiftool path/to/IMAGEFILE6134.jpg
ExifTool Version Number         : 12.34
File Name                       : IMAGEFILE6134.jpg
Directory                       : path/to
File Size                       : 910 KiB
File Modification Date/Time     : 2021:11:04 21:34:11-07:00
File Access Date/Time           : 2021:11:06 13:13:57-07:00
File Inode Change Date/Time     : 2021:11:06 15:25:18-07:00
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 300
Y Resolution                    : 300
Image Width                     : 4896
Image Height                    : 3264
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 4896x3264
Megapixels                      : 16.0


>~/bin/Image-ExifTool-12.34/exiftool -s path/to/IMAGEFILE6134.jpg.json
ExifToolVersion                 : 12.34
FileName                        : IMAGEFILE6134.jpg.json
Directory                       : path/to
FileSize                        : 967 bytes
FileModifyDate                  : 2021:11:04 21:34:11-07:00
FileAccessDate                  : 2021:11:06 13:14:39-07:00
FileInodeChangeDate             : 2021:11:06 15:25:16-07:00
FilePermissions                 : -rw-r--r--
FileType                        : JSON
FileTypeExtension               : json
MIMEType                        : application/json
CreationTimeFormatted           : Sep 28, 2021, 2:36:21 AM UTC
CreationTimeTimestamp           : 1632796581
Description                     :
GeoDataAltitude                 : 0.0
GeoDataLatitude                 : 39.539273699999995
GeoDataLatitudeSpan             : 0.0013488999999991288
GeoDataLongitude                : -122.3326425
GeoDataLongitudeSpan            : 0.0013489999999906188
GeoDataExifAltitude             : 0.0
GeoDataExifLatitude             : 0.0
GeoDataExifLatitudeSpan         : 0.0
GeoDataExifLongitude            : 0.0
GeoDataExifLongitudeSpan        : 0.0
ImageViews                      : 16
PhotoLastModifiedTimeFormatted  : Nov 3, 2021, 4:38:54 AM UTC
PhotoLastModifiedTimeTimestamp  : 1635914334
PhotoTakenTimeFormatted         : Sep 24, 2021, 4:00:04 PM UTC
PhotoTakenTimeTimestamp         : 1632499204
Title                           : IMAGEFILE6134.jpg
Url                             : https://lh3.googleusercontent.com/asdlfjkfwoijgfRLDEj7ivGaPzjt97VVitypedrandomstuffheretoreplacethehash0JkwQktohaVsgjnEVK7OksnQ5BFUKUrfGbjk


>~/bin/Image-ExifTool-12.34/exiftool -r -d %s -tagsfromfile "%d/%F.json" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json path/to/IMAGEFILE6134.jpg
======== path/to/IMAGEFILE6134.jpg [1/1]
Warning: Month '49' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - path/to/IMAGEFILE6134.jpg.json
Warning: No writable tags set from path/to/IMAGEFILE6134.jpg.json
Nothing changed in path/to/IMAGEFILE6134.jpg
    0 image files updated
    1 image files unchanged


>lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-ia32:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: OracleServer
Description: Oracle Linux Server release 7.9
Release: 7.9
Codename: n/a


>uname -a
Linux myhost 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 11:20:39 PDT 2021 x86_64 x86_64 x86_64 GNU/Linux


>~/bin/Image-ExifTool-12.34/exiftool -ver
12.34


In this case I see a '49' string in the epoch time. I'm not sure if the epoch version is the issue or if this is a red herring.



(Edit - split each command to separate code /code boxes)


StarGeek

It helps when you list the command you're using, but in this case I suspect you're not converting the epoch time to a standard date.  Try adding
-d %s
to the command.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

chono

This is the command I was using:

>~/bin/Image-ExifTool-12.34/exiftool -r -d %s -tagsfromfile "%d/%F.json" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json path/to/IMAGEFILE6134.jpg


(Its in the code: box .. but forum made the box much smaller than full content and put a scroll on it. I'll edit the original post)

StarGeek

Quote from: chono on November 06, 2021, 06:37:22 PM
In this case I see a '49' string in the epoch time. I'm not sure if the epoch version is the issue or if this is a red herring.

It is the issue somehow. Exiftool is ignoring the -d %s for some reason and treating "1632499204" as if it were the date as per FAQ #5, 3rd paragraph (starts "Having said this).

I dug out an old test takeout I had, edited the json time stamp to "1632499204" and ran your command.  It worked properly here on Windows.

The only thing I can think of offhand is that you're missing a Perl library.  What is the output of this command?
exiftool -ver -v

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

This seems to work for me here too:

> cat a.json
[
  {
    "PhotoTakenTimestamp": 1632499204
  }
]
> exiftool a.jpg -tagsfromfile %f.json "-exif:datetimeoriginal<phototakentimestamp" -d %s -v2
======== a.jpg
Setting new values from a.json
Writing ExifIFD:DateTimeOriginal
Rewriting a.jpg...
  Editing tags in: APP0 APP1 ExifIFD IFD0 JFIF
  Creating tags in: APP1 ExifIFD IFD0
JPEG APP1 (182 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
    - ExifIFD:DateTimeOriginal = '2019:01:02 03:04:05'
    + ExifIFD:DateTimeOriginal = '2021:09:24 12:00:04'
JPEG DQT (130 bytes):
JPEG SOF0:
JPEG DHT (73 bytes):
JPEG SOS
    1 image files updated
> exiftool -v -ver
ExifTool version 12.34
Perl version 5.018004 (-C0)
Platform: darwin
Optional libraries:
  Archive::Zip                 1.37
  Compress::Zlib               2.06
  Digest::MD5                  2.52
  Digest::SHA                  5.84_02
  IO::Compress::Bzip2          2.060
  POSIX::strptime              0.13
  Time::Local                  1.2300
  Unicode::LineBreak           2016.003
  IO::Compress::RawDeflate     2.060
  IO::Uncompress::RawInflate   2.060


It is the POSIX::strptime that does the date/time conversion here.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

chono

Aha - strptime not installed:

>~/bin/Image-ExifTool-12.34/exiftool -v -ver
ExifTool version 12.34
Perl version 5.016003 (-C0)
Platform: linux
Optional libraries:
  Archive::Zip                 (not installed)
  Compress::Zlib               2.061
  Digest::MD5                  2.52
  Digest::SHA                  5.85
  IO::Compress::Bzip2          2.061
  POSIX::strptime              (not installed)
  Time::Local                  1.2300
  Unicode::LineBreak           (not installed)
  IO::Compress::RawDeflate     2.061
  IO::Uncompress::RawInflate   2.061



chono

And in case anyone is in my situation - and needs to install this library locally here are the steps I took:


>mkdir ~/lib/perl5
>wget https://cpan.metacpan.org/authors/id/G/GO/GOZER/POSIX-strptime-0.13.tar.gz
>tar -vxzf POSIX-strptime-0.13.tar.gz
>cd POSIX-strptime-0.13
>perl Makefile.PL PREFIX=~/lib/perl5
>make
>make test
>make install


And to test:

>export PERL5LIB=~/lib/perl5/lib64/perl5
>~/bin/Image-ExifTool-12.34/exiftool -v -ver
ExifTool version 12.34
Perl version 5.016003 (-C0)
Platform: linux
Optional libraries:
  Archive::Zip                 (not installed)
  Compress::Zlib               2.061
  Digest::MD5                  2.52
  Digest::SHA                  5.85
  IO::Compress::Bzip2          2.061
  POSIX::strptime              0.13
  Time::Local                  1.2300
  Unicode::LineBreak           (not installed)
  IO::Compress::RawDeflate     2.061
  IO::Uncompress::RawInflate   2.061



chono

And thanks for the tips @StarGeek and @Phil Harvey!
Once I understood what lib was missing the fix was straightforward.

StarGeek

Alternatively, you could use
cpanm POSIX::strptime
or if cpanm isn't installed, then cpan should work
cpan POSIX::strptime
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

I am sort of surprised you didn't see a warning about the missing library.  I think there should have been one, but maybe you needed to use the -v option to see it.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).