gino0631 / nextcloud-metadata

A Nextcloud plugin for displaying file metadata.
GNU Affero General Public License v3.0
84 stars 17 forks source link

Suggesting reading metadata from json file #110

Open itsdapi opened 8 months ago

itsdapi commented 8 months ago

I export my Google photo and it comes with not just the photo but a JSON file that contains most of the data. The photo contains no metadata. Is there a way to read metadata from that JSON file?

{
  "title": "IMG_1411.HEIC",
  "description": "",
  "imageViews": "0",
  "creationTime": {
    "timestamp": "1682922142",
    "formatted": "2023年5月1日 UTC 06:22:22"
  },
  "photoTakenTime": {
    "timestamp": "1664348988",
    "formatted": "2022年9月28日 UTC 07:09:48"
  },
  "geoData": {
    "latitude": 22.05xxxx33,
    "longitude": 111.76xxxx89,
    "altitude": 27.524xxxxx30539,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "geoDataExif": {
    "latitude": 22.05xxxx33,
    "longitude": 111.76xxxx89,
    "altitude": 27.524xxxxx30539,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "url": "https://photos.google.com/photo/AF1QxxxxxxxxxxxxxxxxxBs5xxxxxxxwv5W",
  "googlePhotosOrigin": {
    "mobileUpload": {
      "deviceType": "IOS_PHONE"
    }
  }
}
Bl4DEx commented 7 months ago

Hi @itsdapi, having the Metadata as a separate json file isn't a common setup I would say. Also, almost every pictures and videos format out there supports the basic Metadata. Therefore, the feature you are requesting will most likely not benefit many people.

Here is some input for you to resolve this issue on your side: Parse the json file per image yourself and just add the Metadata into the picture (or video). With this in place, this will app will correctly resolve all the Metadata

gino0631 commented 7 months ago

@itsdapi thanks for the interesting request. @Bl4DEx thanks for the useful input. There are cases when metadata is stored separately (see #21 for example), so I would be open regarding how to proceed. @itsdapi how these files are named? Like, what could be the way to find the corresponding JSON file, having a photo file?

itsdapi commented 7 months ago

@itsdapi thanks for the interesting request. @Bl4DEx thanks for the useful input. There are cases when metadata is stored separately (see #21 for example), so I would be open regarding how to proceed. @itsdapi how these files are named? Like, what could be the way to find the corresponding JSON file, having a photo file?

Hi, I uploaded some examples

The JSON file is right next to the original photos with the same file name but an extra JSON ext suffix.

In my case, there are usually two types of photos, one is shot with a camera that contains most of the metadata in photos themselves, and another one is coming from somewhere and contains no metadata at all. In this case, JSON file would only contain the date that was uploaded to Google Photo or the date it was created.

Because the second type of photo doesn't contain metadata at all, so nextcloud treated its date as the date when it was downloaded (in my case most of the photos are stuck together). Using the metadata to separate would be nice.

itsdapi commented 7 months ago

Hi @itsdapi, having the Metadata as a separate json file isn't a common setup I would say. Also, almost every pictures and videos format out there supports the basic Metadata. Therefore, the feature you are requesting will most likely not benefit many people.

Here is some input for you to resolve this issue on your side: Parse the json file per image yourself and just add the Metadata into the picture (or video). With this in place, this will app will correctly resolve all the Metadata

Sorry for the late reply.

I know the best way to do this is by combining the JSON file with the photos themselves, but I can not find any useful tools that can handle this (I have tried a few and coded it by myself, but no luck doing it all perfectly). So I was thinking loading the JSON file would be a valid solution.

gino0631 commented 7 months ago

@itsdapi loading metadata from the corresponding JSON file seems doable, but that metadata would be displayed in the sidebar tab, i.e. I'm not sure what can be done regarding this part:

nextcloud treated its date as the date when it was downloaded

itsdapi commented 7 months ago

@itsdapi loading metadata from the corresponding JSON file seems doable, but that metadata would be displayed in the sidebar tab, i.e. I'm not sure what can be done regarding this part:

nextcloud treated its date as the date when it was downloaded

yeah, sounds a little bit tricky. I am starting to think writing data into EXIF would be the solution for me.

gino0631 commented 7 months ago

@itsdapi I wouldn't mind to integrate with Nextcloud more deeply, but I doubt if they have a well-documented API for that, so yes, seems tricky. For writing you can take a look at ExifTool - it even supports JSON, though I'm not sure about the compatibility with your files.

farhills commented 3 months ago

@itsdapi I believe this function is already available in the 'memories' app. It has some sort of 'ingest' function to merge the json metadata back into the origin files. I haven't used it personally though, so ymmv.