xemle / home-gallery

Self-hosted open-source web gallery to view your photos and videos featuring mobile-friendly, tagging and AI powered image discovery
https://home-gallery.org
MIT License
836 stars 64 forks source link

Not handling multiple subject tags #149

Closed fire-eggs closed 3 months ago

fire-eggs commented 3 months ago

Trying out the pre-packaged Linux exe. I have some images where I've established multiple Exif.Subject tags. Home-gallery successfully imports those tags, but as a single tag instead of the expected multiple tags.

E.g. if I've used ExifTool to add multiple Subject tags to an image:

exiftool -Subject=castle -Subject=knight knight.jpg

the resulting Exif.Subject string is castle, knight. When imported into home-gallery, those should be two distinct tags.

xemle commented 3 months ago

Hi @fire-eggs

Thank you for reporting the issue. The gallery works as intended. Each subject is treated as single distinct tag castle and knight.

Do I understand you correctly: Your expectation is that multiple subject tags should be imported only as one tag into the gallery joined by a comma , and the resulting tag should be castle, knight?

Can you describe your usecase or current workflow of joined tags? What problem do you like to solve?

Are you aware that you can query single tags by the query language like tag:castle or tag:knight or tag:castle and tag:knight?

fire-eggs commented 3 months ago

Thank you for the quick response! Sorry for being imprecise.

When importing exif subject tags, the currently available Linux exe version of home-gallery does not treat each subject as a distinct tag. The tags are imported as castle, knight. The desired behavior is to import as distinct tags castle and knight.

Here is a screen cap showing the current behavior: image

For the sample image, the three intended-to-be-distinct tags illustration, castle and ex libris have been imported as one combined tag.

I entered the issue because in this code:

const addUniqValues = (result, values) => toArray(values).forEach(value => {
  if (!result.includes(value)) {
    result.push(value)
  }
})

from packages/database/src/media/tags.js I don't see any handling of comma-separated-values, which the original exif tags are stored as. My understanding of javascript is limited so I may have misunderstood.

xemle commented 3 months ago

Hi @fire-eggs

That is strange that the subjects are joined as one single tag.

Would you mind to send the example image with the subjects so I can better check and reproduce it?

Could it be that the image contains the compound subject already? Have you checked it via exiftool -json -Subject knight.jpg | jq . and are the subjects an array as in my example picture?

[
  {
    "SourceFile": "knight.jpg",
    "Subject": [
      "castle",
      "knight"
    ]
  }
]

knight

fire-eggs commented 3 months ago

Sure thing. knight.jpg attached. Here is the output from exiftool:

kevin@BRIX2:~/dpix/000to-sort4$ exiftool -json -Subject knight.jpg | jq
[
  {
    "SourceFile": "knight.jpg",
    "Subject": [
      "castle",
      "finis",
      "knight",
      "illustration"
    ]
  }
]
kevin@BRIX2:~/dpix/000to-sort4$ exiftool -Subject knight.jpg
Subject                         : castle, finis, knight, illustration

knight

Kevin

xemle commented 3 months ago

Thank you for your image. The compound tag castle, finis, knight, illustration comes from the HierarchicalSubject:

exiftool -json knight.jpg | jq . | grep -C2 castle
    "Format": "image/jpeg",
    "Subject": [
      "castle",
      "finis",
      "knight",
      "illustration"
    ],
    "HierarchicalSubject": "castle, finis, knight, illustration",
    "ColorMode": "RGB",
    "ICCProfileName": "",

So while the tag extraction of Subject works as expected, you HierarchicalSubject value is not split. A quick internet search seems that it is not documented, how to split a HierarchicalSubject. A forum entry of exiftool about HierarchicalSubject split the values by the pipe char |. So I am not sure what is the correct way for the algorithm of HomeGallery...

Do you have a suggestion?

fire-eggs commented 3 months ago

I just figured it out myself. Nice catch!

Digging a little bit, it seems the HierarchicalSubject tag is specific to Adobe Lightroom (from here, search for "lightroom").

This forum discussion shows there could be multiple tag hierarchies. On consideration, I think the current behavior of home-gallery is "correct". To use the example from that forum, if I establish a tag hierarchy of Army|vehicle|Fennek, that is a single "tag" for home-gallery. If I search for Fennek that should match in that "tag".

I believe this is a tagging error on my part: I should not be duplicating the Subject tags into the HierarchicalSubject field. I don't use Adobe Lightroom, and can no longer remember my reasoning behind the duplication. I'll be fixing my images.

xemle commented 3 months ago

Awesome. Happy that we found a solution.

Are there any open issues regarding your HierarchicalSubject or can we close this issue?

fire-eggs commented 3 months ago

Nothing further from me. Thank you for the conversation and thank you for the project!