Help joining Json from Google Takeout

Started by Cobito, August 28, 2019, 02:43:33 AM

Previous topic - Next topic

Cobito

Hello! First of all sorry if this was already posted, i couldnt find anything that i could completely understand, as English isnt my first language nor i have a lot of knowledge in cmd/terminal commands. As i said in the title, I downloaded my whole G Photos and have lots of Json, which first i deleted, while most of my photos kept their metadata, many didnt being the date captured the day the photos were downloaded, so got to ExifTool as i want to "join" or merge(dont know the correct term) the json to the many types of media files that i have, but in every tutorial or guide i couldnt fully understand what i should do, neither i know if it would be the same in MacOs or windows, is there any explained(maybe with images or video, better) tutorial of how should i do it? Thanks a lot!

Phil Harvey

This depends a lot on the format of the JSON you want to import and the type of files you want to write.  Can you post a sample of the JSON and tell me what types of files you want to write this metadata to?

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

Cobito

File types are Jpg, PNG, HEIC, MOV, MP4, Vob AVI. there may be another types left, but this are the main. would it be the same if i post any .json? for example this is one (of more than 10k images+videos)
{
  "title": "2006 049.jpg",
  "description": "",
  "imageViews": "0",
  "creationTime": {
    "timestamp": "1454292090",
    "formatted": "1 feb. 2016 2:01:30 UTC"
  },
  "modificationTime": {
    "timestamp": "1563982867",
    "formatted": "24 jul. 2019 15:41:07 UTC"
  },
  "geoData": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "geoDataExif": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "photoTakenTime": {
    "timestamp": "1160774218",
    "formatted": "13 oct. 2006 21:16:58 UTC"
  }
}



Mainly i want to keep the dates of the image/videos, to later sort them, also in this case i dont have geotags because its a very old photo, but if possible i`d like to keep them

thanks!

-Nico

StarGeek

** An example was posted while typing this, and I can see that the data is still the same.

Unless something has changed, the Google Takeout json should return the following tag names when running exiftool on the json file. 
Title, defaults to original filename
Description
Url, direct URL to view image, WARNING, ignores privacy settings
ImageViews
CreationTimeTimestamp, Time file was uploaded in Epoch seconds UTC
CreationTimeFormatted, Time file was uploaded UTC using -d format code: %b %d, %Y, %I:%M:%S %p
ModificationTimeTimestamp, Epoch seconds UTC
ModificationTimeFormatted, Date format code: %b %d, %Y, %I:%M:%S %p UTC
GeoDataLatitude
GeoDataLongitude
GeoDataAltitude
GeoDataLatitudeSpan
GeoDataExifLongitudeSpan
GeoDataExifLatitude
GeoDataExifLongitude
GeoDataExifAltitude
GeoDataExifLatitudeSpan
GeoDataExifLongitudeSpan
PhotoTakenTimeTimestamp, Epoch seconds UTC
PhotoTakenTimeFormatted, Date format code: %b %d, %Y, %I:%M:%S %p UTC

The GeoData* tags (not the GeoDataExif* tags) are based upon City/State/Country entered in the Google photos website, which doesn't allow for exact gps coordinates.

I did come across one case while trying to help someone on StackExchange who had Google Takeout json code which could not be read by exiftool.  I'm sure of that person's home country but it wasn't a native English speaker, so it might have just been a translation problem

* 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 is a bit tricky because the formatted dates are not in a very useful format, but ExifTool can use the timestamps if you have POSIX::strptime available.  So the command would be something like this:

exiftool -@ my.args DIR

with this "my.args" file:

-p
%s
-tagsfromfile
@
-createdate<CreationTimeTimestamp
-datetimeoriginal<PhotoTakenTimeTimestamp
-modifydate<ModificationTimeTimestamp
-description
-title
-gpslatitude<GeoDataAltitude
-gpslongitude<GeoDataLongitude
-gpsaltitude<GeoDataAltitude
-gpsposition#<$GeoDataLatitude $GeoDataLongitude $GeoDataAltitude


But since you are writing to so many different types of files, you may have to add extra entries to write tags that are specific to this format.

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

StarGeek

One thing to take note of is that the time stamps are in UTC and would need to be adjusted for the time zone in image files.

Plus, it might be a good idea to add -wm cg to avoid overwriting any existing data.

Also, I believe that it should be
-TagsFromFile
%d%F.json

as the json files are usually named after the filename with .json appended e.g IMG_0001.jpg.json
* 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

Quote from: StarGeek on August 28, 2019, 11:37:05 AM
One thing to take note of is that the time stamps are in UTC and would need to be adjusted for the time zone in image files.

That should be handled properly by the command I gave (I think).

QuoteAlso, I believe that it should be
-TagsFromFile
%d%F.json

Right.  Thanks.

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

StarGeek

The thing about the time stamp is that Google adjusts it when it's uploaded, at least for photos.  I haven't checked on what it does for video files.

So if I take a picture at noon west coast time US today (2019:08:28 12:00:00-07:00 or %s 1567018800), when I upload it to Google photos, Google saves the time as 2019:08:28 19:00:00 UTC or 1567044000.  Which, when copying back into the file, would be correct for video files, but off by the time zone for image files.

Also, CreationTimeTimestamp is the time when the file was uploaded to Google Photos, which IMO, is irrelevant to the creation of the file.

* 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).

Cobito

#8
Wow, so first thanks for your answer and sorry that i didnt checked earlier.
it seems that i need way more knowledge than i have. is there a user friendly guide or something like so? as i really want to do this, but cant understand half the concepts you talk about.

Edit 1:
like how can i make a my.args file
and what do i do with what stargeek said that should be added
i`d really appreciate it!

Edit 2:
i managed to make a my.args file, but still cant get exiftool to edit all files(i have more than 5k folders)


thanks again for being so helpful!
have a great day!