immich icon indicating copy to clipboard operation
immich copied to clipboard

fix(server): Allow saving empty description tag to sidecar

Open dahool opened this issue 5 months ago • 2 comments

Description

Currently, clearing an embedded Description or ImageDescription tag is not possible when the file contains an embedded entry. ExifTool treats an empty string as a directive to delete the tag, meaning it will fall back to reading the embedded tag if the sidecar's tag is not defined. This change enables writing an empty string to the sidecar for these tags, thereby overriding the embedded description and effectively clearing it from the asset's displayed metadata.

Fixes #15990 Fixes #19168

Added new e2e test. (requires updated asset : https://github.com/immich-app/test-assets/pull/18 )

sidecar with empty tags

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 13.00'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:description>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'/>
   </rdf:Alt>
  </dc:description>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
  <tiff:ImageDescription>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'/>
   </rdf:Alt>
  </tiff:ImageDescription>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

Checklist:

  • [X] I have performed a self-review of my own code
  • [X] I have made corresponding changes to the documentation if applicable
  • [X] I have no unrelated changes in the PR.
  • [X] I have confirmed that any new dependencies are strictly necessary.
  • [X] I have written tests for new code (if applicable)
  • [X] I have followed naming conventions/patterns in the surrounding code
  • [X] All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • [X] All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

dahool avatar Jun 14 '25 19:06 dahool

How will this handle existing assets with an empty description? Will it write an empty Description field for every asset when it refreshes metadata? I am not sure if that is desired. Currently sidecar files are generated when metadata is changed/set, this would result in every single file getting a sidecar (if I am interpreting the patch correctly).

It seems like we should only set this special empty tag if the underlying asset has a description that is manually deleted.

On second read I guess this is only triggering when a XMP would be written anyway, so that probably won't be an issue.

mmomjian avatar Jun 14 '25 19:06 mmomjian

How will this handle existing assets with an empty description? Will it write an empty Description field for every asset when it refreshes metadata? I am not sure if that is desired. Currently sidecar files are generated when metadata is changed/set, this would result in every single file getting a sidecar (if I am interpreting the patch correctly).

This process does not affect existing asset metadata unless a specific update operation is performed. It exclusively writes empty Description tags to the sidecar file when the tag is intentionally set to an empty string during metadata modification.

dahool avatar Jun 14 '25 19:06 dahool

This seems like something that should be addressed upstream, perhaps in exiftool-vendored.

mertalev avatar Oct 17 '25 18:10 mertalev