Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bulk join json with jpg from Google Takeout

I wish to leave Google photos, and I have downloaded all my photos using Google Takeout. Now I have a boatload of folders containing both json files (that I think contains exif data) and images. The structure looks like this: home/user/Billeder/Takeout/Google Photos/2011-06-09/file.json. home/user/Billeder/Takeout(2)/Google Photos/2011-07-09/file.json.

I want to join the json data with the correct images and organize the images in folders that correspond to their creation date. I have been looking at Exiftool, but all answers found so far only shows how to do this for a single image. What I'm looking for is a way to join all the data with the correct images in bulk.

I'm trying to do this in linux command line. Is there a way to do this?

like image 537
Lasserh Avatar asked Feb 03 '17 12:02

Lasserh


People also ask

How to batch merge Google Takeout photos with JSON files?

Click Quick Action -> and select Merge Google Takeout json files to photos menu item, open your Google Takeout folder, then it will automatically process all the photos in the Google Takeout folder. After it's completed, you can import the processed Google Photos to iCloud Photos or Apple Photo library.

How do I combine Google Takeout files?

To use this method, open the “Takeout 2” folder, copy the “Google Photos” folder, navigate to the first “Takeout” folder, and paste into that folder. The computer will prompt you whether you want to cancel, replace, or merge the folders—choose “Merge” and the computer will handle the rest!

How do I upload photos from Google Takeout?

Go to the Google Photos account that will receive the photos. Drag and drop the folder you downloaded from Takeout to the new account. Select your upload size then click Continue. The pictures and videos uploaded will appear in the new account.

What are JSON files Google Photos?

For each file there is a JSON file. This file is only useful if you have added any information like captions or descriptions to the photo within Google Photos. The information about where and when a photo was taken and any camera settings are stored in the photo file - they don't need the JSON file.


1 Answers

Exiftool now has the ability to do this as of ver 10.47.

In my testing, I've seen two different formats for the json filename, some where it is filename.ext.json and some where it is filename.json (no extension in the json filename). Here are two command to cover either situation. If you have a mixtures, as I do, run both.

Files with extension in the json filename
exiftool -tagsfromfile '%d/%F.json' '-ImageTag<JsonTag' FileOrDir

Files without extension in the json filename
exiftool -tagsfromfile '%d/%f.json' '-ImageTag<JsonTag' FileOrDir

Replace FileOrDir with the file or directory you wish to process. Replace ImageTag with the name of the tag in the image you want to copy to. Replace JsonTag with the name of the tag from the json file you wish to copy from. If you are on Windows instead of linux, use double quotes instead of single quotes.

Here are some of the more useful tags that I've encountered in the json file and my suggestions where to copy them. Two of the tag names, Description and Title, are the same as the related XMP tags, so they don't need to be redirected into the image tag name and can be left simply as -Description or -Title in the above commands.
description: Description of the file. The appropriate placement for this would be IPTC:Caption-Abstract, XMP:Description, and EXIF:ImageDescription. You could copy these with '-Caption-Abstract<Description', -Description, or '-ImageDescription<Description'.
title: Name of the uploaded file. This can be copied into Title, ObjectDescription or PreservedFileName.
people: Not sure but I'm guessing that if the file has had people tagged in a program such as Picasa, this would be the list of names, most likely from the RegionPersonDisplayName.
url: This is an URL that the image can be downloaded from. WARNING: It is a publicly shared URL and even if the image is marked private, it can still be downloaded with this URL.
GeoInfoAltitude_, GeoInfoLatitude_, and GeoInfoLongitude_: If the uploaded file was geotagged, these will be the Altitude, Latitude, and Longitude for the image. These would best be copied into GPSAltitude, GPSLatitude, GPSLatitudeRef, GPSLongitude, and GPSLongitudeRef. Because of the nature of GPS tags (unsigned), image that are in the Western and/or Southern hemisphere must also have the Ref tags set.

Example commands:
Copy gps tags
exiftool -tagsfromfile '%d/%F.json' '-GPSAltitude<GeoDataAltitude' '-GPSLatitude<GeoDataLatitude' '-GPSLatitudeRef<GeoDataLatitude' '-GPSLongitude<GeoDataLongitude' '-GPSLongitudeRef<GeoDataLongitude' FileOrDir

Copy Keywords:
exiftool -tagsfromfile '%d/%F.json' '-Keywords<Tags' '-Subject<Tags' FileOrDir

Copy Description:
exiftool -tagsfromfile '%d/%F.json' '-Caption-Abstract<Description' '-ImageDescription<Description' -Description FileOrDir

Copy all the data from the JSON to the files, modifying the original files (2020):

exiftool -r -d %s -tagsfromfile "%d/%F.json" "-GPSAltitude<GeoDataAltitude" "-GPSLatitude<GeoDataLatitude" "-GPSLatitudeRef<GeoDataLatitude" "-GPSLongitude<GeoDataLongitude" "-GPSLongitudeRef<GeoDataLongitude" "-Keywords<Tags" "-Subject<Tags" "-Caption-Abstract<Description" "-ImageDescription<Description" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext jpg -overwrite_original FileOrDir

Edit (Jan 2018): As always, Google will change everything. The above GeoInfo* tags are deprecated according to the comment below and have been replaced by GeoDataAltitude, GeoDataLatitude, and GeoDataLongitude.

Edit (Oct 2020): Update commands for 2020 JSON format

Exiftool can read Json files, so if there are other changes, running the command exiftool -s FILE.Json will list all the tags and available data that can be copied.

like image 193
StarGeek Avatar answered Sep 29 '22 07:09

StarGeek