Writing GoogleTakeout json data to my images - warnings I don't understand

Started by craigl, November 20, 2023, 03:00:58 PM

Previous topic - Next topic

craigl

I want to write the PeopleName and PhotoTakenTimeFormatted from Google Takeout json files to my images and movies I've downloaded. I wandered around the forum and used this command to discover the names of the keywords in the json files and got these results:

 exiftool -g1 -a -s DadGirlsandEthan.jpg.json
    PeopleName                      : Scott Smith, Kaley Breanne Smith, Annabelle Kate Smith
    PhotoTakenTimeFormatted         : Oct 17, 2008, 4:30:35ΓÇ»PM UTC
    PhotoTakenTimeTimestamp         : 1224261035

Then I used this command to add those keywords to the Description in the jpg file:

>exiftool -TagsFromFile DadGirlsandEthan.jpg.json "-Description+<PhotoTakenTimeFormatted" "-+Description+<PeopleName" -d %s DadGirlsandEthan.jpg
Warning: Shift value for XMP-xmp:Description is not a number - DadGirlsandEthan.jpg.json
Warning: No writable tags set from DadGirlsandEthan.jpg.json
    0 image files updated
    1 image files unchanged

I think there may be some weird characters in the json PhotoTakenTimeFormatted field but don't know how to deal with that. The attached file has the odd characters, but the pasted one below probably does not. I don't understand why exiftool warns that there are no writable tags from DadGirlsandEthan.jpg.json.

Any help would be appreciated.

~Craig

The json file:

{
  "title": "DadGirlsandEthan.jpg",
  "description": "",
  "imageViews": "2",
  "creationTime": {
    "timestamp": "1608241807",
    "formatted": "Dec 17, 2020, 9:50:07 PM UTC"
  },
  "photoTakenTime": {
    "timestamp": "1224261035",
    "formatted": "Oct 17, 2008, 4:30:35 PM 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
  },
  "people": [{
    "name": "Scott Smith"
  }, {
    "name": "Kaley Breanne Smith"
  }, {
    "name": "Annabelle Kate Smith"
  }],
  "url": "https://photos.google.com/photo/AF1QipMNaDZvf7KJ1ceio7Q1b5N09EsloaGhZPFiWW0",
  "googlePhotosOrigin": {
    "driveDesktopUploader": {
      "version": "BACKUP_AND_SYNC"
    }
  }
}

P.S. Attached are the json and jpeg files I'm working with.


Phil Harvey

The "+<" syntax is for adding items to a List-type tag (which XMP:Description is not).  To write them to the Description, you would do this:

exiftool -TagsFromFile %d%f.%e.json "-Description<$PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

The -d option won't work for that poorly-formatted date value.

But it might make more sense to do something like this to write the timestamp to a date/time tag instead (here I process an entire directory).

exiftool -TagsFromFile %d%f.%e.json -d %s "-datetimeoriginal<PhotoTakenTimeTimestamp" "-description<PeopleName" -ext jpg DIR

But note that any previously-existing Description would be overwritten by both commands.

- 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

As usual, I'm too slow, but posting anyway as it gives (I think) an option for when there is a pre-existing Description and a warning about overwriting existing time stamps.

The Description tag is a simple string tag.  The +< is used for either adding to a List type tag (see [FAQ #17](https://exiftool.org/faq.html#Q17)) or to shift a number tag.  Description is neither of those.

If the Description is empty to start with, then you could use this command
exiftool -TagsFromFile DadGirlsandEthan.jpg.json "-Description<$PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

If there is the possibilty that there is a pre-existing Description, then you could use this
exiftool -TagsFromFile DadGirlsandEthan.jpg.json "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

You do not want to run these commands more than once on the same file as it will just keep adding data to the end.

I removed the -d (-dateFormat) option as it doesn't affect this command.  If you are also copying the date from the unformatted time, then you would add it back in but I highly suggest you double check the files first to make sure you're not overwriting a time stamp already in the file with the inaccurate UTC one.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

craigl

So far so good. Thank you to both. Both replies are helpful. Thanks for the explanations about list types, how to get multiple fields concatenated and your example for processing the directory.

StarGeek, I have a question about preserving the description. I used your command exactly and a few variations I thought of, but even so I could not preserve the original information and tack on the people and time-taken date. Am I missing something?

I did this to add a description:
    exiftool "-description=plain happy" DadGirlsandEthan.jpg

Then this to add the date and names:
    exiftool -TagsFromFile DadGirlsandEthan.jpg.json "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

The Description is then:
...
Thumbnail Length                : 5153
XMP Toolkit                    : Image::ExifTool 12.67
Description                    :  Oct 17, 2008, 4:30:35ΓÇ»PM UTC Scott Petersen, Kaley Breanne Petersen, Annabelle Kate Petersen
Format                          : image/jpeg
Flash Fired                    : True
Flash Function                  : False
Flash Mode                      : Auto

~Craig

Phil Harvey

Hi Craig,

Quote from: craigl on November 20, 2023, 09:23:47 PMexiftool -TagsFromFile DadGirlsandEthan.jpg.json "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

Ah, tricky.  This is reading all tags from the .json file, but the  .json file doesn't have this description.

But cool-new-feature-of-ExifTool to the rescue!:

exiftool -TagsFromFile DadGirlsandEthan.jpg.json -file1 DadGirlsandEthan.jpg "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$File1:Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

(note that for some reason File1:Description must have a capital "D" or it gives a "TAG not defined" warning even if it exists -- I'll have to fix this.)

- Phil

Edit: I've found the reason for the case-sensitivity issue, and this will be fixed in ExifTool 12.71.
...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: Phil Harvey on November 20, 2023, 09:38:22 PMAh, tricky.  This is reading all tags from the .json file, but the  .json file doesn't have this description.

But cool-new-feature-of-ExifTool to the rescue!:

So tricky I fooled myself.  I see that problem now.

I really have to take the time to learn more about this feature.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

craigl

Thank you. Have a busy morning but will put this in motion this afternoon!

~Craig

craigl

Hi Gentlemen,

Sorry to be a pest, but I'm still not successful. I'm consistently getting this warning:

    Warning: [minor] Tag 'File1' not defined - DadGirlsandEthan.jpg.json

My environment:
ExifTool Version Number        : 12.70
OS Name    Microsoft Windows 11 Home
Version    10.0.22621 Build 22621

I'm stuck so could use your advice,

Thanks,
Craig

EXPLANATION

I tried a lot of things trying to understand how this option works, but below find what is representative of the whole effort:

============
[This one came directly from your post.]

c:\temp\>exiftool -TagsFromFile DadGirlsandEthan.jpg.json -file1 DadGirlsandEthan.jpg "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$File1:Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg
Warning: [minor] Tag 'File1:Description' not defined - DadGirlsandEthan.jpg.json
    1 image files updated

c:\temp\>exiftool -TagsFromFile DadGirlsandEthan.jpg.json -file1 DadGirlsandEthan.jpg "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$File1:$Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg
Warning: [minor] Tag 'File1' not defined - DadGirlsandEthan.jpg.json
    1 image files updated

c:\temp\>exiftool -TagsFromFile DadGirlsandEthan.jpg.json -file1 DadGirlsandEthan.jpg "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<${File1}:Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg
Warning: [minor] Tag 'File1' not defined - DadGirlsandEthan.jpg.json
    1 image files updated

====================

QUESTION #2
While I was frustrated with not understanding the -file option I looked into parsing out the portions of PhotoTakenTimeFormatted that I wanted in the Description field.

This did not work:

    ${PhotoTakenTimeFormatted;/(\w{3} \d{1,2}, \d{4})/; $1}

But this did:

    ${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//g}

I would have felt better with something like the first method, it just seems more reliable. Is there a way to return the match? Do you have a more forgiving regex to get the date? They all have the same form: "Oct 17, 2008, 4:30:35 PM UTC"

Phil Harvey

Ah, you are right.  I should have tested this with the -tagsfromfile.  But it is good to find this... I'll fix it.  In the mean time you can do it this way:

exiftool -file1 DadGirlsandEthan.jpg.json -file2 DadGirlsandEthan.jpg "-Description<$File1:PhotoTakenTimeFormatted $File1:PeopleName" "-Description<$File2:Description $File1:PhotoTakenTimeFormatted $File1:PeopleName" DadGirlsandEthan.jpg

Sorry for the extra iteration.  I think it should work this time.

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

Phil Harvey

Ah.  I had tested it with -tagsFromFile, but just not using a constant file name.  This should work too:

exiftool -TagsFromFile %f.%e.json -file1 DadGirlsandEthan.jpg "-Description<$PhotoTakenTimeFormatted $PeopleName" "-Description<$File1:Description $PhotoTakenTimeFormatted $PeopleName" DadGirlsandEthan.jpg

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

craigl

Well, thank you so much. This combination worked fine. Kind of an odd edge case that the constant filename would not be recognized. Glad that you discovered this and many thanks for sticking with me.

~Craig

Phil Harvey

Yeah, it would seem like an odd edge case, but tags from a constant file name may be read just once instead of for each different target file, so ExifTool reads them before processing the first target file, which unfortunately was before the -fileNUM option was processed.

- Phil

Edit: This quirk was fixed in version 12.73
...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 ($).

craigl

#12
Phil and StarGeek,

Happy Thanksgiving to you both!!!

I have the command just the way I want, but it does not work recursively. It's processing everything in the current directory, but not descending into the sub-directories. I thought maybe it was due to one of my options and tried many different forms, but only a bare bones exiftool without the -tagsFromFile seems to work.

To help recreate this issue I zipped up a small directory structure which is attached here.

I did so many iterations that I also made a batch file to report what was happening. Also attached.

Here is my command that I am executing at the root directory - recurse-with-tagsfromfile:

exiftool -TagsFromFile %f.%e.json -file1 %f.%e "-Description<${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName" "-Description<$File1:Description ${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName"  "-Caption-Abstract<${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName"  "-Caption-Abstract<$File1:Caption-Abstract ${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName" -r .

Have a good holiday! I would not expect you to address this today.

Thanks again,
~Craig

StarGeek

The command is looking for matching files in the current directory, not the matching files in the same subdirectory as the file being processed.  Try this change
-TagsFromFile %d%f.%e.json -file1 %d%f.%e
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

craigl

#14
That did the job. That should do it. Thanks a bunch ~Craig  :D  :D

For anyone Writing GoogleTakeout face and description data from the JSON sidecars to your images here is the command that ultimately worked for me. This was run after the Google Takeout files were merged into my master directory structure where all my photos are, not just what's on Google Photos. Unwanted photos were deleted, and duplicates removed with Duplicate Cleaner Pro. Then, this help from exiftool:

exiftool -TagsFromFile %d%f.%e.json -file1 %d%f.%e "-Description<${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName" "-Description<$File1:Description ${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName"  "-Caption-Abstract<${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName"  "-Caption-Abstract<$File1:Caption-Abstract ${PhotoTakenTimeFormatted;s/, \d{1,2}:.*$//} $PeopleName" -r .

NOTE: I needed to fill in Description and Caption-Abstract because movie files apparently do not have Caption-Abstract and I use Picasa (still) to organize my photos and it uses Caption-Abstract for captions on the photos. I wanted the names there so I could complete the name tagging that Picasa does so nicely.

https://exiftool.org/forum/index.php?topic=15411.0