TheLastGimbus / GooglePhotosTakeoutHelper

Script that organizes the Google Takeout archive into one big chronological folder
https://aur.archlinux.org/packages/gpth-bin
Apache License 2.0
3.88k stars 191 forks source link

Is GPTH setting the wrong Date Taken field? Modify Date vs File Modification Date/Time #149

Closed wjhladik closed 1 year ago

wjhladik commented 1 year ago

gpth-windoza --input \temp\temp\takeout --output \temp\temp\new\gpth --divide-to-dates --copy

Using 3.3.1. As far as I can tell not much was changed in any photo's exif data. Date Taken was not set (at least according to Windows), descriptions were not added, other json fields were not added to the photo's exif data. It did move the photos to the new directory structure under the output directory. And I have a ton of photos before 1970 so I did not even consider those (we need a solution there).

But here's some before and after data focusing on one particular photo from 1979.

C:\temp\temp\Takeout\Takeout\Google Photos\Photos from 1979>dir 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b*
 Volume in drive C is Windows
 Volume Serial Number is 7625-F5EC

 Directory of C:\temp\temp\Takeout\Takeout\Google Photos\Photos from 1979

12/20/2022  09:35 AM             1,413 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4.json
12/20/2022  09:35 AM           549,063 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4b(1).jpg
12/20/2022  09:35 AM           338,694 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4b.jpg
               3 File(s)        889,170 bytes
               0 Dir(s)  695,706,292,224 bytes free

Notice the name of the json file which is cut short by one character. Hopefully you are accounting for this. Here's what's in the json file including several fields I modified in Google Photos that I expected would be copied into the exif data of the output file:

C:\temp\temp\Takeout\Takeout\Google Photos\Photos from 1979>type 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4.json
{
  "title": "1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4be2c.jpg",
  "description": "Independence Bowl, Chris, Beth, Steve, Tammy, Faye, Tony, Lisa, Scott, Kim, Michelle, Bill T.",
  "imageViews": "258",
  "creationTime": {
    "timestamp": "1581272919",
    "formatted": "Feb 9, 2020, 6:28:39 PM UTC"
  },
  "photoTakenTime": {
    "timestamp": "314132400",
    "formatted": "Dec 15, 1979, 7:00:00 PM UTC"
  },
  "geoData": {
    "latitude": 32.5251516,
    "longitude": -93.75017880000001,
    "altitude": 0.0,
    "latitudeSpan": 0.12861050000000337,
    "longitudeSpan": 0.13410839999999918
  },
  "geoDataExif": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "people": [{
    "name": "Michelle"
  }, {
    "name": "Lisa "
  }, {
    "name": "Tammy"
  }, {
    "name": "Scott"
  }, {
    "name": "Bill"
  }, {
    "name": "Tony"
  }],
  "url": "https://lh3.googleusercontent.com/gRDcbVFfR8EcqAlygkh_ulvrO_VBgs4_Zc5m9HX6MYxmTGkfh32TZLc3jfV4fmGaeciLdqXMZ-9sWRUUwCcocIqbxjiWurNz9ZmBjXWj",
  "googlePhotosOrigin": {
    "mobileUpload": {
      "deviceFolder": {
        "localFolderName": ""
      },
      "deviceType": "ANDROID_PHONE"
    }
  },
  "photoLastModifiedTime": {
    "timestamp": "1670669775",
    "formatted": "Dec 10, 2022, 10:56:15 AM UTC"
  }
}

Now the before and after exiftool view of the photo file in question:

C:\temp\temp\Takeout\Takeout\Google Photos\Photos from 1979>exiftool -G 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4b.jpg
[ExifTool]      ExifTool Version Number         : 12.19
[File]          File Name                       : 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4b.jpg
[File]          Directory                       : .
[File]          File Size                       : 331 KiB
[File]          File Modification Date/Time     : 2022:12:20 09:35:18-05:00
[File]          File Access Date/Time           : 2023:01:17 11:13:08-05:00
[File]          File Creation Date/Time         : 2022:12:19 05:50:46-05:00
[File]          File Permissions                : -rw-rw-rw-
[File]          File Type                       : JPEG
[File]          File Type Extension             : jpg
[File]          MIME Type                       : image/jpeg
[File]          Exif Byte Order                 : Big-endian (Motorola, MM)
[File]          Image Width                     : 3000
[File]          Image Height                    : 2106
[File]          Encoding Process                : Baseline DCT, Huffman coding
[File]          Bits Per Sample                 : 8
[File]          Color Components                : 3
[File]          Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
[JFIF]          JFIF Version                    : 1.01
[JFIF]          Resolution Unit                 : None
[JFIF]          X Resolution                    : 1
[JFIF]          Y Resolution                    : 1
[EXIF]          Software                        : GooglePhotoScan
[EXIF]          Modify Date                     : 2020:02:09 12:47:20
[EXIF]          Create Date                     : 2020:02:09 12:47:20
[XMP]           XMP Toolkit                     : Adobe XMP Core 5.1.0-jc003
[XMP]           Photo Id                        : 7adc2095-f758-4e8a-8d30-da730eabcef3
[XMP]           Export Session Id               : cc156131-4ac8-4149-8994-601bb44f6dac
[XMP]           App Name                        : PhotoScan
[XMP]           App Version                     : 74937
[Composite]     Image Size                      : 3000x2106
[Composite]     Megapixels                      : 6.3

C:\temp\temp\Takeout\Takeout\Google Photos\Photos from 1979>exiftool -G **\temp\temp\new\gpth\1979\12\1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4b.jpg**
[ExifTool]      ExifTool Version Number         : 12.19
[File]          File Name                       : 1581270440551-d356c6b2-6178-49af-bcdf-b308a5b4b.jpg
[File]          Directory                       : /temp/temp/new/gpth/1979/12
[File]          File Size                       : 331 KiB
[File]          File Modification Date/Time     : 1979:12:15 14:00:00-05:00
[File]          File Access Date/Time           : 2023:01:17 11:02:00-05:00
[File]          File Creation Date/Time         : 2023:01:17 10:27:00-05:00
[File]          File Permissions                : -rw-rw-rw-
[File]          File Type                       : JPEG
[File]          File Type Extension             : jpg
[File]          MIME Type                       : image/jpeg
[File]          Exif Byte Order                 : Big-endian (Motorola, MM)
[File]          Image Width                     : 3000
[File]          Image Height                    : 2106
[File]          Encoding Process                : Baseline DCT, Huffman coding
[File]          Bits Per Sample                 : 8
[File]          Color Components                : 3
[File]          Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
[JFIF]          JFIF Version                    : 1.01
[JFIF]          Resolution Unit                 : None
[JFIF]          X Resolution                    : 1
[JFIF]          Y Resolution                    : 1
[EXIF]          Software                        : GooglePhotoScan
[EXIF]          Modify Date                     : 2020:02:09 12:47:20
[EXIF]          Create Date                     : 2020:02:09 12:47:20
[XMP]           XMP Toolkit                     : Adobe XMP Core 5.1.0-jc003
[XMP]           Photo Id                        : 7adc2095-f758-4e8a-8d30-da730eabcef3
[XMP]           Export Session Id               : cc156131-4ac8-4149-8994-601bb44f6dac
[XMP]           App Name                        : PhotoScan
[XMP]           App Version                     : 74937
[Composite]     Image Size                      : 3000x2106
[Composite]     Megapixels                      : 6.3

Notice the Modify Date field which stayed the same at 2/9/2020, but the File Modification Date/Time which changed to what was in the json file 12/15/1979. This is what I wanted for the photo's Date Taken. Exiftool does not actually show that field as being present but when I use Windows explorer to view the directory and select Date Taken as one of the header fields it shows 2/9/2020 as the date taken. So Windows must be looking at Modify Date instead of the field gpth set. Here's a chart that explains this:

https://exiftool.org/forum/index.php/topic,6591.msg32875.html#msg32875

TheLastGimbus commented 1 year ago

Sadly, yes: https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/discussions/133#discussioncomment-4476604

gpth currently does not write exifs back :disappointed: - do you specifically need this feature? Did use google photos date/location editing a lot? Or you have lot of photos with stripped exif?

Thing is, implementing this will be hard, and i need to know how much priority to put into this...

If you want quick solution to this, exiftool can help you: exiftool "-AllDates<FileModifyDate" /folder/

I have a ton of photos before 1970

Ah, shit. Guess i need to learn ffi after all :/

json file which is cut short

Yep, json file names are stripped to 51 chars, and gpth does try to search for them

wjhladik commented 1 year ago

Me personally... I've scanned hundreds (maybe thousands) of old photos and then inside GP I applied gps location tags and descriptions and date/time fixes. I could have done all this outside GP but it is quite easy to apply these changes in bulk using the GP web interface. So I can't say whether you should spend time on it in your code or make an interface to call exiftool to do it for you or not address it at all. I'd benefit, but not sure about others.

TheLastGimbus commented 1 year ago

scanned hundreds (maybe thousands) of photos

Damn... i may looking into it - would suck if you had all of this data gone...

If https://github.com/brendan-duncan/image/issues/457 gets resolved, i will add it instantly soon 😅! Otherwise, i may look into ffi'ing to exiv2 or something in some time