Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): read additional lens exif tags #17125

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Snowknight26
Copy link
Contributor

@Snowknight26 Snowknight26 commented Mar 26, 2025

Description

exiftool provides a tag named Composite:LensID that is derived from several dozen different lens-related tags since manufacturers don't have a standard way of writing camera lens information.

In an effort to provide the best lens information possible in immich, LensID is now read, with a fallback of Composite:LensSpec, Composite:LensType and the existing LensModel.

Out of about 85k RAW files that I had access to, exiftool provided a Composite:LensID tag for all of them, though few with questionable values.

This is a drastic improvement over the current approach, which, with the same sample of RAW images, read only about 8% of the lens information.

LensID distribution

LensID Count
20.7mm 120
26.3mm f/2.2 7
Canon EF 100mm f/2.8L Macro IS USM 11
Canon EF 24-70mm f/2.8L USM 24
Canon EF 40mm f/2.8 STM 3
Canon EF 50mm f/1.8 STM 42
Canon EF-S 18-135mm f/3.5-5.6 IS STM 263
Canon EF-S 18-55mm f/3.5-5.6 IS II 58
DJI MFT 15mm F1.7 ASPH 997
E 70-350mm F4.5-6.3 G OSS 25
FE 24-70mm F2.8 GM II 12
LEICA D VARIO-ELMARIT 14-50mm 1359
LEICA DG 100-400mm F4.0-6.3 18
LEICA DG 10-25mm F1.7 738
LEICA DG 12-60mm F2.8-4.0 239
LEICA DG 50-200mm F2.8-4.0 95
LEICA DG 8-18mm F2.8-4.0 194
Leica DG Vario-Elmar 100-400mm F4.0-6.3 Asph. Power OIS 4094
Leica DG Vario-Elmarit 12-60mm F2.8-4 Asph. Power OIS 8641
Leica DG Vario-Elmarit 50-200mm F2.8-4 Asph. Power OIS 10432
Leica DG Vario-Elmarit 8-18mm F2.8-4 Asph. 6401
Leica DG Vario-Summilux 10-25mm F1.7 Asph. 22346
LUMIX G 14mm F2.5 648
LUMIX G 20mm F1.7 5280
LUMIX G 25mm F1.7 4
Lumix G 25mm F1.7 Asph. 171
LUMIX G 42.5mm F1.7 739
Lumix G 42.5mm F1.7 Asph. Power OIS 2086
LUMIX G MACRO 30mm F2.8 11
Lumix G Macro 30mm F2.8 Asph. Mega OIS 292
LUMIX G VARIO 100-300mm F4.0-5.6 3
Lumix G Vario 100-300mm F4.0-5.6 Mega OIS 75
OLYMPUS M.75mm F1.8 906
Olympus M.Zuiko Digital ED 75mm F1.8 1208
Sony E 18-135mm F3.5-5.6 OSS 561
Sony E 70-350mm F4.5-6.3 G OSS 2303
Sony FE 200-600mm F5.6-6.3 G OSS + 1.4X Teleconverter 426
Sony FE 24-70mm F2.8 GM II 2791
Sony FE 24-70mm F4 ZA OSS 44
Sony FE 35mm F2.8 ZA 3
Sony FE 70-200mm F2.8 GM OSS II 62
Sony FE 90mm F2.8 Macro G OSS 993
Tamron 28-75mm F2.8 Di III RXD 2
Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical [IF] Macro 80
Unknown (0 ff ff) 21
Unknown (8 01 10) 11512
Voigtlander NOKTON 50mm F1 Aspherical 77
Zeiss Batis 25mm F2 84
Zeiss Batis 85mm F1.8 6

LensType distribution

LensSpec Count
  83842
Leica DG Vario-Elmarit 12-60mm F2.8-4 Asph. Power OIS 1738
Leica DG Vario-Elmarit 8-18mm F2.8-4 Asph. 916
Lumix G 42.5mm F1.7 Asph. Power OIS 9
Unknown (8 01 10) 2

LensSpec distribution

N/A, didn't have any

LensModel distribution

LensModel Count
  78644
---- 77
28-75mm 80
E 18-135mm F3.5-5.6 OSS 561
E 28-75mm F2.8-2.8 2
E 70-350mm F4.5-6.3 G OSS 2328
EF100mm f/2.8L Macro IS USM 11
EF24-70mm f/2.8L USM 24
EF40mm f/2.8 STM 3
EF50mm f/1.8 STM 42
EF-S18-135mm f/3.5-5.6 IS STM 263
EF-S18-55mm f/3.5-5.6 IS II 51
FE 200-600mm F5.6-6.3 G OSS + 1.4X Teleconverter 426
FE 24-70mm F2.8 GM II 2803
FE 24-70mm F4 ZA OSS 44
FE 35mm F2.8 ZA 3
FE 70-200mm F2.8 GM OSS II 62
FE 90mm F2.8 Macro G OSS 993
ZEISS Batis 1.8/85 6
ZEISS Batis 2/25 84

There are other LensID examples that are less than idea, such as the example in #17050, but I think that's better than not reading the data at all.

Various findings:

  • Sony, Canon populate LensModel
  • Panasonic populates LensType
  • Nikon populates LensSpec?

Implements #17050

How Has This Been Tested?

  • Refreshed metadata for an asset with each tag

Screenshots (if appropriate)

Checklist:

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

@Snowknight26
Copy link
Contributor Author

Snowknight26 commented Mar 27, 2025

Couple outstanding questions based on some example LensID values I've seen:

  1. Are we ok with values like the following:
    1. ----
    2. Unknown (0 ff ff)
    3. Unknown (8 01 10)
    4. Unknown (E1 40 19 36 2C 35 DF 0E) Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023) ?
    5. Unknown 6-30mm
    6. Sony FE 100mm F2.8 STF GM OSS or Sony FE 70-200mm F2.8 GM OSS or Sony FE 70-200mm F2.8 GM OSS + 1.4X Teleconverter or Sony FE 70-200mm F2.8 GM OSS + 2X Teleconverter or Sigma 70-200mm F2.8 DG OS HSM | S

If yes.. cool, nothing to do.
If no:

  1. Should we consolidate ---- and Unknown (*) into a single value (thinking null)?
    • This covers 1.i, 1.ii and 1.iii
  2. Should we consolidate ---- and Unknown* into a single value (thinking null)?
    • This covers 1.i, 1.ii, 1.iii, 1.iv, and 1.v
    • Might be a loss of information for 1.iv
  3. Should we consolidate ---- and Unknown (*)* into a single value (thinking null)?
    • This covers 1.i,1.ii, 1.iii and 1.iv
    • Might be a loss of information for 1.iv
  4. Should we attempt to infer the lens from a value like Unknown (E1 40 19 36 2C 35 DF 0E) Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023) ? as Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023)?
    • This covers 1.iv

@Snowknight26 Snowknight26 changed the title fix(server): read additional lens exif tags feat(server): read additional lens exif tags Mar 30, 2025
@Snowknight26 Snowknight26 marked this pull request as ready for review March 30, 2025 20:12
@zackpollard
Copy link
Contributor

zackpollard commented Mar 31, 2025

Couple outstanding questions based on some example LensID values I've seen:

1. Are we ok with values like the following:
   
   1. `----`
   2. `Unknown (0 ff ff)`
   3. `Unknown (8 01 10)`
   4. `Unknown (E1 40 19 36 2C 35 DF 0E) Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023) ?`
   5. `Unknown 6-30mm`
   6. `Sony FE 100mm F2.8 STF GM OSS or Sony FE 70-200mm F2.8 GM OSS or Sony FE 70-200mm F2.8 GM OSS + 1.4X Teleconverter or Sony FE 70-200mm F2.8 GM OSS + 2X Teleconverter or Sigma 70-200mm F2.8 DG OS HSM | S`

I personally think all the unknown and ---- values should be ignored entirely, we shouldn't have those come through to the application. As for vi, it seems pretty useless too, it's giving like 4 different possible lenses. Aside from that, the values in the rest of the list seem much better.

@Snowknight26
Copy link
Contributor Author

I personally think all the unknown and ---- values should be ignored entirely, we shouldn't have those come through to the application. As for vi, it seems pretty useless too, it's giving like 4 different possible lenses. Aside from that, the values in the rest of the list seem much better.

Didn't feel comfortable adding code for that last example without the risk of false positives but I've now made the others work the same way as if the exif info wasn't set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lens info not being displayed on some raw photos.
3 participants