immich-go icon indicating copy to clipboard operation
immich-go copied to clipboard

Creating albums from Takeout using the "archive" command

Open fakkoweb opened this issue 6 months ago • 10 comments
trafficstars

Hi,

I am solely using immich with readonly external libraries and I want to add a new library which will contain my google takeout content. It contains both YYYY folders and album folders (so yes, likely duplicates).

Here is the command I used:

./immich-go archive from-google-photos --write-to-folder=/immich_ready --include-unmatched=TRUE --include-untitled-albums=TRUE --partner-shared-album=TRUE "/takeout/Google Photos" Other flags like --people-tag and --sync-albums should be default to true.

My intent is to produce a folder structure (with sidecar files) that immich can read and import with albums and people.

Now the result is the bunch of YYYY/YYYY-MM folders only. I don't see any reference in any json to an album and I am starting to think that some documented flags only work if i directly upload to immich... am I getting this right?

Any suggestion in this case?

fakkoweb avatar May 05 '25 10:05 fakkoweb

Now the result is the bunch of YYYY/YYYY-MM folders only. I don't see any reference in any json to an album and I am starting to think that some documented flags only work if i directly upload to immich... am I getting this right?

Yes, the archive command prepares a file system for a immich-go upload command but not to be used as an external library. I should consider writing XMP files to fit your use case. But XMP format is messy, and there are no good standards for features like albums, and I'm not sure there is anything for people.

simulot avatar May 05 '25 16:05 simulot

Very clear thank you.

I want to keep those files as an external library... but still would love the option to create an album with those in immich. Could be done as a second step, like:

  1. run immich-go to create archive, albums and people info are stored somewhere
  2. ask immich to Scan the library
  3. run immich-go again to create that info on top of the scanned library (since now immich has reference to each of those)

fakkoweb avatar May 05 '25 17:05 fakkoweb

This would result to an upload of your take out into the immich's internal library.

You may give a look to a project called Immich power tools: https://github.com/varun-raj/immich-power-tools

simulot avatar May 05 '25 17:05 simulot

This would result to an upload of your take out into the immich's internal library.

If you follow my 1-2-3 steps, it wouldn't upload anything. Of course, I am talking about a non-existent feature in immich-go, which is used in 2 different times (step 1 and step 3). No upload would be required, because you would scan the external library with immich (so no upload) then immich-go would simply create the albums pointing to those assets.

Thanks for the power tools suggestion, though.

fakkoweb avatar May 05 '25 19:05 fakkoweb

Let me know how it goes. This is a scenario I haven't imagined

simulot avatar May 06 '25 06:05 simulot

Yes, the archive command prepares a file system for a immich-go upload command but not to be used as an external library.

While going through json files generated by immich-go, i found something like this:

{
  "software": "immich-go version:0.26.0,  commit:ebe411d788f041200e6b1d489fa47afd2e080907, date:2025-05-03T10:45:54Z",
  "fileName": "PXL_20250407_124807912.jpg",
  "latitude": 28.304780599999997,
  "longitude": -16.568183299999998,
  "dateTaken": "2025-04-07T12:48:07Z",
  "albums": [
    {
      "title": "MyAlbumName"
    }
  ]
}

So immich-go does export album data, even though embedded in this json file.

Do you have a reference json file that immich-go exports, with all possible fields it can export? It would be really helpful for me to develop my script!

I am also interested to know if this json file contains duplicated info, because I see that info like latitude/longitude are also already inside the image... but I am not sure if immich-go does both things.

For reference, you can consider I am using the flags in my first post above.

fakkoweb avatar May 06 '25 21:05 fakkoweb

Sure it does. I have chose this special format because I think that the XMP format can't handle the album concept, and therefore immich won't create album on this basis.

simulot avatar May 07 '25 10:05 simulot

Sure it does. I have chose this special format because I think that the XMP format can't handle the album concept, and therefore immich won't create album on this basis.

Nice! Do you have a reference json file that immich-go exports, with all possible fields it might export? It would be really helpful for me to develop my script!

You also confirm immich-go does not write same info into photos metadata? Or does it? (just my curiosity here)

fakkoweb avatar May 07 '25 10:05 fakkoweb

Here is the structure used to read and write those JSON: https://github.com/simulot/immich-go/blob/01ed80c03f541e2e05baa6d430374f93f70d7664/internal/assets/metadata.go#L13-L28

And for substructures: https://github.com/simulot/immich-go/blob/01ed80c03f541e2e05baa6d430374f93f70d7664/internal/assets/album.go#L7-L13

https://github.com/simulot/immich-go/blob/01ed80c03f541e2e05baa6d430374f93f70d7664/internal/assets/tag.go#L5-L9

You also confirm immich-go does not write same info into photos metadata? Or does it? (just my curiosity here)

The JSON is written with the data known by Immich-go. It could be the same info as in the photo.

simulot avatar May 07 '25 14:05 simulot

I was pleased to find the the archive json files included album info. I discoved that the following SQL would show people/face data for photos. I thought that I might use some powershell to take this data from the csv produced and move to the archive json files.

My impression is that the metadata json is not used by immich-go for any imports/uploads via immich-go or other tools so I was thinking of adding another substructure for people/face.

It would be great if the immich-go archive json was crammed with everything that Immich server had stored about a file. There may be issues with some of the AI data structures but other data might be accessible?

Here is how I got face data to a csv.

COPY ( SELECT f.id AS face_id, f."assetId" AS asset_id, a."originalPath", f."personId" AS person_id, p.name AS person_name, f."boundingBoxX1", f."boundingBoxY1", f."boundingBoxX2", f."boundingBoxY2" FROM public.asset_faces f JOIN assets a ON f."assetId" = a.id LEFT JOIN person p ON f."personId" = p.id ) TO '/tmp/OrgDocker_faces_export.csv' CSV HEADER;

WraithBane avatar May 13 '25 17:05 WraithBane