Google Takeout copying all data possible from .json to .jpg

Started by Ry, July 19, 2023, 11:24:02 PM

Previous topic - Next topic

Ry

Hi all,

Newbie here migrating away from Google Photos. Thanks for having me on your forum.

I have .jpg files with no exif data and trying to transfer at least date-time (and everything else if possible) from their corresponding .json files.

Example files in test/ directory:
IMG-20191006-WA0003.jpg
IMG-20191006-WA0003.jpg.json

I've tried variations of this:
exiftool -tagsfromfile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original test/
Which returns:
Warning: Month '33' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - test/IMG-20191006-WA0003.jpg.json
Warning: No writable tags set from test/IMG-20191006-WA0003.jpg.json
    1 directories scanned
    0 image files updated
    1 image files unchanged

So I checked if exiftool can see the date tag:
exiftool  --json:all test/IMG-20191006-WA0003.jpg.json
Output (seems it cannot see date taken, which should be 2019):
ExifTool Version Number         : 12.60
File Name                       : IMG-20191006-WA0003.jpg.json
Directory                       : test
File Size                       : 890 bytes
File Modification Date/Time     : 2023:07:11 19:24:52+08:00
File Access Date/Time           : 2023:07:20 09:54:54+08:00
File Inode Change Date/Time     : 2023:07:20 09:46:07+08:00
File Permissions                : -rw-rw-r--
File Type                       : JSON
File Type Extension             : json
MIME Type                       : application/json

But when I look inside IMG-20191006-WA0003.jpg.json it includes the correct "photoTakenTime" (full file also attached)
  },
  "photoTakenTime": {
    "timestamp": "1570339253",
    "formatted": "Oct 6, 2019, 5:20:53 AM UTC"
  },

Is this happening because of an error on my part? Is it the formatting of the .json file? I've seen there are many similar questions around but they didn't seem to help in my case.

Thank you

wywh

Try this:

exiftool -d %s -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original .
-d %s date/time formatting option to accept timestamps in seconds since the epoch.

https://exiftool.org/filename.html#codes

Or copy selected tags from the .json to the .jpg (I don't know if there is an option to automatically copy all possible .json tags?):

exiftool -overwrite_original -d %s -tagsFromFile '%d/%F.json' '-GPSLatitude<GeoDataLatitude' '-GPSLatitudeRef<GeoDataLatitude' '-GPSLongitude<GeoDataLongitude' '-GPSLongitudeRef<GeoDataLongitude' '-Caption-Abstract<Description' '-Description<Description' '-AllDates<PhotoTakenTimeTimestamp' -ext jpg .
--json:all excludes all json tags so use -json:all instead:

exiftool -a -G1 -s -json:all .
Check also how to ignore any 0.0 latitude and longitude in .json (otherwise the location will be in the Atlantic for location-less images). And a Favorite tag tip. And a tip if Google Takeout truncates long filenames so jpg filenames over 47 chars fail to get a matching .json

https://exiftool.org/forum/index.php?topic=12905.0

- Matti

Ry

Thanks so much for the reply.

Quote from: wywh on July 20, 2023, 09:49:08 AM--json:all excludes all json tags so use -json:all instead:
Thank you, that helps a lot!

Quote from: wywh on July 20, 2023, 09:49:08 AMTry this:

Code Select Expand
exiftool -d %s -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original .

Unfortunately this and the other suggested command is returning the same error:
Warning: Month '33' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - test/IMG-20191006-WA0003.jpg.json
Warning: No writable tags set from test/IMG-20191006-WA0003.jpg.json
    1 directories scanned
    0 image files updated
    1 image files unchanged

I'm guessing it doesn't like the format of the timestamp in the .json file:  ?
[JSON]          PhotoTakenTimeFormatted         : Oct 6, 2019, 5:20:53 AM UTC
[JSON]          PhotoTakenTimeTimestamp         : 1570339253


I inspected with
exiftool IMG-20191006-WA0003.jpg
Which returned:
ExifTool Version Number         : 12.60
File Name                       : IMG-20191006-WA0003.jpg
Directory                       : .
File Size                       : 303 kB
File Modification Date/Time     : 2023:07:11 19:24:50+08:00
File Access Date/Time           : 2023:07:20 22:52:56+08:00
File Inode Change Date/Time     : 2023:07:20 22:52:56+08:00
File Permissions                : -rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Image Width                     : 900
Image Height                    : 1600
Encoding Process                : Progressive DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 900x1600
Megapixels                      : 1.4

I'm noticing that the 'Date/Time Original' is not present before or after I run the command.


wywh

Maybe the quotes are incorrect. Are you using Mac, Linux or Windows?

- Matti

Ry

Quote from: wywh on July 20, 2023, 01:07:58 PMMaybe the quotes are incorrect. Are you using Mac, Linux or Windows?
I'm on linux.

I tried changing to " and still get the same warnings ???

wywh

Quote from: Ry on July 20, 2023, 08:33:15 PMstill get the same warnings

That works on the Mac. Maybe the lone $ must be quoted on Linux? Also this works on the Mac:

exiftool -d '%s' -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original .
For some reason '-d %s' does not work:

exiftool '-d %s' -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original .
Invalid TAG name: "d %s"
Ignored superfluous tag name or invalid option: -d %s
Warning: Month '33' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - ./IMG-20191006-WA0003.jpg.json
Warning: No writable tags set from ./IMG-20191006-WA0003.jpg.json

- Matti

Phil Harvey

-d and %s must be separate arguments.  If you quote them together like this '-d %s' then they are a single argument, which won't work.

It should work with -d %s.  (Mac and Linux quoting are the same.)

If it doesn't, please show us the exact command you are using and tell what version of ExifTool you have (exiftool -ver).

- 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 ($).

Ry

Quote from: Phil Harvey on July 21, 2023, 08:24:29 AMIt should work with -d %s.  (Mac and Linux quoting are the same.)

If it doesn't, please show us the exact command you are using and tell what version of ExifTool you have (exiftool -ver).

Thanks for clarifying. Unfortunately it returns the same error.

The command I'm using:
exiftool -d %s -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original test/

Version info:
Exiftool version: 12.60 (I've also downloaded and tried 12.64 separately with same result).
Perl v5.36.1 built for x86_64-linux-thread-multi

.json example file is also attached: IMG-20191006-WA0003.jpg.json

Phil Harvey

Your command works for me with 12.64 on MacOS.  It should work fine with 12.60 as well.

> exiftool -d %s -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original -v2 tmp
======== tmp/IMG-20191006-WA0003.jpg
Setting new values from tmp/IMG-20191006-WA0003.jpg.json
Writing MIE-Doc:DateTimeOriginal
Writing QuickTime:DateTimeOriginal if tag exists
Writing UserData:DateTimeOriginal
Writing CanonRaw:DateTimeOriginal if tag exists
Writing Kodak:DateTimeOriginal if tag exists
Writing Reconyx:DateTimeOriginal if tag exists
Writing Reconyx:DateTimeOriginal if tag exists
Writing XMP-exif:DateTimeOriginal if tag exists
Writing ExifIFD:DateTimeOriginal
Warning: Use of uninitialized value in join or string in Reconyx:DateTimeOriginal (ValueConvInv) - tmp/IMG-20191006-WA0003.jpg.json
Rewriting tmp/IMG-20191006-WA0003.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes QuickTime UserData XMP
  Creating tags in: APP1 ExifIFD IFD0 MIE-Doc UserData
Creating APP1:
  Creating IFD0
    + IFD0:XResolution = '72' (mandatory)
    + IFD0:YResolution = '72' (mandatory)
    + IFD0:ResolutionUnit = '2' (mandatory)
    + IFD0:YCbCrPositioning = '1' (mandatory)
  Creating ExifIFD
    + ExifIFD:ExifVersion = '0232' (mandatory)
    + ExifIFD:DateTimeOriginal = '2019:10:06 01:20:53'
    + ExifIFD:ComponentsConfiguration = '1 2 3 0' (mandatory)
    + ExifIFD:FlashpixVersion = '0100' (mandatory)
    + ExifIFD:ColorSpace = '65535' (mandatory)
JPEG DQT (130 bytes)
JPEG SOF0:
JPEG DHT (416 bytes)
JPEG SOS
    1 directories scanned
    1 image files updated
> exiftool tmp -datetimeoriginal
======== tmp/IMG-20191006-WA0003.jpg
Date/Time Original              : 2019:10:06 01:20:53
======== tmp/IMG-20191006-WA0003.jpg.json
    1 directories scanned
    2 image files read
...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 ($).

Ry

Quote from: Phil Harvey on July 21, 2023, 11:25:52 PMYour command works for me with 12.64 on MacOS.  It should work fine with 12.60 as well.
Thank you for checking.

It looks like it's something to do with Fedora 38, perhaps some dependency that isn't being installed?

I've installed ubuntu on a different system and it works there with exiftool 3.4

I'll post here if I figure out the issue with Fedora, but I feel I'll probably just do my work on Ubuntu  :-\

Thank you for your time, everyone!


Phil Harvey

There is no difference in Fedora that should cause this not to work.

Something else must be happening.  Could you show a log of an attempt with the last command that I used?  (including -v2)

- 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 ($).

Ry

Here is the output on the Fedora 38 system with exiftool 12.6:

> exiftool -d %s -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original -v2 test/
======== test/IMG-20191006-WA0003.jpg
Setting new values from test/IMG-20191006-WA0003.jpg.json
Warning: Month '33' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - test/IMG-20191006-WA0003.jpg.json
Warning: No writable tags set from test/IMG-20191006-WA0003.jpg.json
Nothing changed in test/IMG-20191006-WA0003.jpg
    1 directories scanned
    0 image files updated
    1 image files unchanged

Phil Harvey

Interesting.  Do you perhaps have a config file active?  Try this command:

exiftool -config '' -d '%s' -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original -v2 test/

Also, just for the heck of it, I've tried quoting '%s'

- 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 ($).

Ry

I'm don't think I have a config file running? I didn't set anything like that and this is a fairly fresh install of Fedora too. I initially installed with  dnf install perl-Image-ExifTool then later tried the 12.64 download directly. All dependencies resolved and no issues reported.

Your suggestion:
> exiftool -config '' -d '%s' -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original -v2 test/

======== test/IMG-20191006-WA0003.jpg
Setting new values from test/IMG-20191006-WA0003.jpg.json
Warning: Month '33' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - test/IMG-20191006-WA0003.jpg.json
Warning: No writable tags set from test/IMG-20191006-WA0003.jpg.json
Nothing changed in test/IMG-20191006-WA0003.jpg
    1 directories scanned
    0 image files updated
    1 image files unchanged

Also tried without quotes on '%s'
> exiftool -config '' -d %s -tagsFromFile '%d/%F.json' '-DateTimeOriginal<PhotoTakenTimeTimestamp' -ext jpg -overwrite_original -v2 test/
======== test/IMG-20191006-WA0003.jpg
Setting new values from test/IMG-20191006-WA0003.jpg.json
Warning: Month '33' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - test/IMG-20191006-WA0003.jpg.json
Warning: No writable tags set from test/IMG-20191006-WA0003.jpg.json
Nothing changed in test/IMG-20191006-WA0003.jpg
    1 directories scanned
    0 image files updated
    1 image files unchanged


Phil Harvey

Wow.  I guess I am out of ideas here, which is very unusual.  I can't see how this could happen because the %s date/time formatting code is parsed by ExifTool, so it should be system independent.

Hmmm.  Wait.  Maybe I am calling the system date/time conversion routine even if only %s is used.  This could be the issue.  I'll investigate this possibility.

Thanks for your help.

- 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 ($).