Copy Google Takeout JSON "description" to IPTC Caption

Started by dr_dean_dean, March 12, 2017, 04:56:13 AM

Previous topic - Next topic

dr_dean_dean

I searched through the forum, but can't find a solution to my challenge. Hope someone cal help.

I exported my Archive Google Picasa Photo albums using Google Takeout. This exports image files into folders for each album with a photo filename and an associated JSON file. For example

/agung
agung.jpg
agung.jpg.json

The json file contains the text that I want to copy to the jpg file as the IPTC caption.

For example, the agung.jpg.json file contains the following text:

"description": "An eruption column towers above Bali",
"title": "agung.jpg",

Is there a way to use ExifTool take the text from the "description" in each JSON file and copy it to its namesake image file EXIF data caption field?

Thanks, Andy

Phil Harvey

Hi Andy,

Currently there is no easy way to do this.  Can you attach one of the JSON files.  Maybe a solution is for me to add support for reading generic JSON files.

- 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

Here's an example I was able to pull from Google Takeout
{
  "tags": [],
  "description": "testing description",
  "title": "2013-02-02",
  "people": [],
  "comments": [],
  "url": "https://(removed)",
  "geoInfo": null,
  "geoInfoExif": null,
  "imageViews": 0,
  "license": null
}
* 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

Great, thanks.  I'll see about adding general JSON support for the next version.

- 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

Quote from: dr_dean_dean on March 12, 2017, 04:56:13 AM
agung.jpg
agung.jpg.json

Is this how your json file was named?  When I tried Google Takeout, my files were 2013-02-02.json and 2013-02-02.jpg, no jpg extension in the json file name.
* 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).

StarGeek

Upon further testing, Google will include the extension in the json filename if there is more than one file in the album, but it won't if there is only one file in the album.
* 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).

StarGeek

The new update seems to deal with this nicely.  This is how I copied the Google Takeout json file's description and tags entries to Caption-Abstract and Keywords.  Due to the different file names for the json files depending upon if there was a single file in the directory or more than one I had to use two different commands. 

Single files:
exiftool -tagsfromfile "%d/%f.json" "-caption-abstract<Description" "-keywords<tags" FileOrDir

multiple files
exiftool -tagsfromfile "%d/%F.json" "-caption-abstract<Description" "-keywords<tags" FileOrDir

I seem to recall that there was a stack exchange question along these lines, so I'll go answer that one.
* 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).

StarGeek

What the heck, Google.  Playing around with this some more, I find two different cases with a single image in a directory, but differently named json files.  One with the extension in the json file name and one without.

Well, one of the above commands or the other will work, so it may require running both.

Here's what I'm finding with the tag names in the json file, Json Tag on left, what it appears to be on right

tags: keywords
description: image description
title: name of uploaded file
people:  Unsure, might be RegionPersonDisplayName list in uploaded file.  Not able to set through web interface.
comments:  ?
url: URL to view file online.  Warning: this is a public sharing url, so even if the image is marked private, it will allow direct viewing of the image.
License: ?
imageViews: Number of times an image was viewed, I assume.
Two sets of GPS info, a GeoInfo group and a GeoInfoExif group.  The obvious useful ones are GeoInfoAltitude_, GeoInfoLatitude_, GeoInfoLongitude_, GeoInfoExifAltitude_, GeoInfoExifLatitude_, and GeoInfoExifLongitude_.  I'm not sure of the difference between the two.  They're both the same in my sample image.  The other tags are GeoInfoCachedSize, GeoInfoIsMutable, GeoInfoLatitude_span_, GeoInfoLongitude_span_, GeoInfoOptional_0_, GeoInfoUninterpreted, and GeoInfoExif versions of these.
* 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

Wow.  Google sure is pulling their weight trying to make the messy world of metadata even more complex. :/
...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 ($).

dr_dean_dean

Hi Guys

Thanks very much for the quick response and the new version of ExifTool to read json files!

I downloaded version 10.47, but I have a couple of questions about getting the command to work.

I attach and example jpg and json file (this has one of the more complicated descriptions in the json file)

I am trying to learn the syntax of the commands. From the Windows cmd window, I started with the following:

exiftool -tagsfromfile "agung.jpg.json" "-caption-<Description" agung.jpg

This informs me that 1 image file was updated, but the EXIF caption is not updated in the file.


Ultimately what I would like to do is run a command within a folder and complete the description to caption write process for every jpg in the folder. I can't yet understand the syntax provided in the earlier reply, but thought I'd ask a question and attach an example file first.


Thanks for your help. I am sure I am not the only one suffering from the Picasa termination.


Andy



Phil Harvey

Hi Andy,

I don't have time to check your files now, but why are you using "-<"?  This is used to remove a tag with a specified value.  Also, the "Caption" tag isn't what you want.  Maybe not even "Caption-Abstract" (which is an IPTC tag).  Perhaps you want EXIF ImageDescription?  Reading FAQ 2 and 3 may help here.  Also, see this post for a list of tags used in Windows metadata.

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

dr_dean_dean

Hi Phil

Thanks - for the tip and link to the FAQ. I was following StarGeek on the use of "-<"

As long as the read from json file is working, I should be able to figure this out.

Cheers, Andy

Phil Harvey

I think the "-<" was simply a missing "Abstract" after the "-" in your command.  Stargeek's command didn't have this problem.
...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 ($).