jsonexiftoolgoogle-photos

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?


Solution

  • 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.