Author Topic: Merging Image Files and Json Files from Google Takeout Yet Again  (Read 134 times)

MikeA01730

  • Newbie
  • *
  • Posts: 2
Hi,

I used Google Takeout to extract all my photos from Google Photos app.  I found that with the exception of images I uploaded to the phone all the images have incorrect time stamps and I'd like to restore the time stamps (both created and modified) in the EXIF information of each image file from the json files.  I already used a Windows batch file to copy every file from the date folder structure that Takeout uses into a single folder to work in. 

I looked around the web and after a lot of false starts found the topic "How to merge image with his .json file (Google Photos takeout)" here and tried to follow it.  Unfortunately It failed.  The command I used is:
exiftool -ext jpg -tagsfromfile %d%f.%e.json -description "-gpslatitude<geodatalatitude" "-gpslatituderef<geodatalatitude" "-gpslongitude<geodatalongitude" "-gpslongituderef<geodatalongitude" "-gpsaltitude<geodataaltitude" "-createdate<creationdatetimestamp" "-datetimeoriginal<phototakentimetimestamp" "-modifydate<modificationtimetimestamp" -d %s Consolidated.tst

When I ran it I got warnings like this for each file:
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - Consolidated.tst/IMG_20170603_093141.jpg
Afterwards the modified stamp of each image file contains the time the exiftool was run and the created stamp is unchanged. 

I ran exiftool -s on one of the files and got 65 lines out.  None of the lines have the word "stamp" in them.  Here are the ones that might be relevant:
ExifToolVersion                 : 12.01
FileName                        : IMG_20200215_141135_1.jpg
FileModifyDate                  : 2020:06:30 15:14:33-04:00
FileAccessDate                  : 2020:06:30 16:19:59-04:00
FileCreateDate                  : 2020:06:30 16:19:59-04:00
ModifyDate                      : 2020:02:15 14:11:35
ExifVersion                     : 0220
DateTimeOriginal                : 2020:02:15 14:11:35
CreateDate                      : 2020:02:15 14:11:35
SubSecCreateDate                : 2020:02:15 14:11:35.353120
SubSecDateTimeOriginal          : 2020:02:15 14:11:35.353120
SubSecModifyDate                : 2020:02:15 14:11:35.353120

I realize that this seems completely inconsistent with what was seen in the Google Takeout topic that I looked at and have no idea why that would be true.  I ran Google Takeout, selected photos only, received the zip files, unpacked them, and then ran a Windows batch file that used the copy command to copy each file into a single folder.  That seems pretty straightforward. 

I'm new to ExifTool and so am a little at sea with it.  Can anyone suggest the best way to proceed? 

Thanks,
Mike

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3795
Re: Merging Image Files and Json Files from Google Takeout Yet Again
« Reply #1 on: July 01, 2020, 04:32:28 PM »
First off, unless you edited the data on the Google Photos website, there is no need to import the data.  Google Photos does not remove any data from the files.

To see all the time related tags for an image, run this command, replacing /path/to/files/ with the actual path to the files
exiftool -time:all -g1 -a -s /path/to/files/

Now, the time data in the json file isn't necessarily going to be what you want to embed in the file.  Google sets that to UTC time, so that time will be off from the original time by the difference in time zone from UTC.

When I ran it I got warnings like this for each file:
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - Consolidated.tst/IMG_20170603_093141.jpg

This is a minor warning and exiftool would have fixed this when it edited the data.

Quote
Afterwards the modified stamp of each image file contains the time the exiftool was run and the created stamp is unchanged. 

What are you looking at the data with?  It sounds like your looking at the file system time stamps (FileModifyDate and FileCreateDate) and not the embedded time stamps.  The underlying OS updates FileModifyDate whenever a file is edited in any way.  You can prevent that by adding the -P (preserve) option to your command.

Quote
I ran exiftool -s on one of the files and got 65 lines out.  None of the lines have the word "stamp" in them.  Here are the ones that might be relevant:
ExifToolVersion                 : 12.01
FileName                        : IMG_20200215_141135_1.jpg
FileModifyDate                  : 2020:06:30 15:14:33-04:00
FileAccessDate                  : 2020:06:30 16:19:59-04:00
FileCreateDate                  : 2020:06:30 16:19:59-04:00
ModifyDate                      : 2020:02:15 14:11:35
ExifVersion                     : 0220
DateTimeOriginal                : 2020:02:15 14:11:35
CreateDate                      : 2020:02:15 14:11:35
SubSecCreateDate                : 2020:02:15 14:11:35.353120
SubSecDateTimeOriginal          : 2020:02:15 14:11:35.353120
SubSecModifyDate                : 2020:02:15 14:11:35.353120

From the looks of it, you don't need to edit the time stamps.  The filename appears to be the date and time the image was taken, 20200215_141135, and that matches the embedded time stamps which are ModifyDate, DateTimeOriginal, and CreateDate.
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.

MikeA01730

  • Newbie
  • *
  • Posts: 2
Re: Merging Image Files and Json Files from Google Takeout Yet Again
« Reply #2 on: July 02, 2020, 02:14:09 PM »
StarGeek,

Thanks for your patient and detailed response. 

As you figured out I was confusing file system time stamps with EXIF data times.  I fully understand the difference between the 3 different types of data and yet I somehow spent an afternoon confusing 2 of them without realizing it.  I apologize for wasting your time. 

What I want is to fix the file system stamps so they agree with the actual times the photos were taken.  This command:
exiftool "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" E:\Temp\Pixel_Photos_Temp\Consolidated\*
worked fine for my mp4 files and most (all but 26) of the jpg files which apparently are damaged in some way.  Probably the best way to fix those is to just manually change the date and time using the Xplorer2 file explorer. 

However all 139 png files failed with the error:
Warning: No writable tags set from Screenshot_20190930-192335.png
After a little research I tried this command:
exiftool "-FileCreateDate<PNG:CreateDate" "-FileModifyDate<PNG:CreateDate" E:\Temp\Pixel_Photos_Temp\Consolidated.tst\*.png
but still got the same error message.  When I run with the -s option on the png file I get this:
ExifToolVersion                 : 12.01
FileName                        : Screenshot_20200617-094710.png
Directory                       : E:/Temp/Pixel_Photos_Temp/Consolidated.tst
FileSize                        : 1450 kB
FileModifyDate                  : 2020:06:30 15:59:25-04:00
FileAccessDate                  : 2020:07:02 13:10:48-04:00
FileCreateDate                  : 2020:07:02 13:10:48-04:00
FilePermissions                 : rw-rw-rw-
FileType                        : PNG
FileTypeExtension               : png
MIMEType                        : image/png
ImageWidth                      : 1080
ImageHeight                     : 1920
BitDepth                        : 8
ColorType                       : RGB
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
SRGBRendering                   : Perceptual
SignificantBits                 : 8 8 8
ImageSize                       : 1080x1920
Megapixels                      : 2.1

Based on my extremely limited understanding of what's going on I thought that would work, but I'm missing something.  I'm not sure how proceed from here.  Any suggestions? 

Thanks,
Mike

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3795
Re: Merging Image Files and Json Files from Google Takeout Yet Again
« Reply #3 on: July 02, 2020, 05:00:44 PM »
However all 139 png files failed with the error:
Warning: No writable tags set from Screenshot_20190930-192335.png
After a little research I tried this command:
exiftool "-FileCreateDate<PNG:CreateDate" "-FileModifyDate<PNG:CreateDate" E:\Temp\Pixel_Photos_Temp\Consolidated.tst\*.png
but still got the same error message.  When I run with the -s option on the png file I get this:

Based on my extremely limited understanding of what's going on I thought that would work, but I'm missing something.  I'm not sure how proceed from here.  Any suggestions? 

See the command in my post to just list the Time related data.  Much easier.

But the output you list shows that other than the file system time stamps, there isn't any time related tags in the file.  Since the name suggests this is a screen shot, this is pretty much normal.  Programs that support metadata in PNG files aren't very common to start with.

But the filename itself appears to hold the date/time that it was taken.  So it's possible to copy that directly into any tags you might want to use.  For example:
exiftool -ext png "-FileCreateDate<Filename" "-FileModifyDate<Filename" "-PNG:CreateDate<Filename"  E:\Temp\Pixel_Photos_Temp\Consolidated.tst\

This command will set the system time stamps as well as the PNG:CreateDate to the date indicated by the filename.  See the third paragraph under FAQ #5 for details.
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.