Author Topic: Copy Google Takeout JSON "description" to IPTC Caption  (Read 4806 times)

dr_dean_dean

  • Newbie
  • *
  • Posts: 3
Copy Google Takeout JSON "description" to IPTC Caption
« on: March 12, 2017, 04:56:13 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #1 on: March 12, 2017, 09:20:37 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2748
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #2 on: March 12, 2017, 10:23:24 AM »
Here's an example I was able to pull from Google Takeout
Code: [Select]
{
  "tags": [],
  "description": "testing description",
  "title": "2013-02-02",
  "people": [],
  "comments": [],
  "url": "https://(removed)",
  "geoInfo": null,
  "geoInfoExif": null,
  "imageViews": 0,
  "license": null
}
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #3 on: March 12, 2017, 10:31:39 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2748
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #4 on: March 12, 2017, 11:54:24 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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2748
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #5 on: March 14, 2017, 07:40:19 PM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2748
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #6 on: March 20, 2017, 04:11:12 PM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2748
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #7 on: March 20, 2017, 04:39:10 PM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #8 on: March 20, 2017, 09:36:27 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

dr_dean_dean

  • Newbie
  • *
  • Posts: 3
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #9 on: March 26, 2017, 06:21:42 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #10 on: March 26, 2017, 10:21:56 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

dr_dean_dean

  • Newbie
  • *
  • Posts: 3
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #11 on: March 26, 2017, 09:59:08 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Copy Google Takeout JSON "description" to IPTC Caption
« Reply #12 on: March 27, 2017, 03:27:23 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).