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

cleanup exif data #16491

Merged
merged 2 commits into from
Mar 19, 2024
Merged

cleanup exif data #16491

merged 2 commits into from
Mar 19, 2024

Conversation

zisoft
Copy link
Collaborator

@zisoft zisoft commented Mar 19, 2024

See discussion in #16479

It turned out that exiv2 gives a whole zoo of manufacturer specific values for the white balance. In some cases where a camera value has no representation by exiv2, the color temperature value is returned, in a not well formated way with trailing spaces.

Improvements/fixes:

  • remove trailing spaces
  • not defined and unknown are now treated as the darktable default unnamed
  • entries are now compared case-insensitive before they get written to the database. This avoids having duplicates like Cloudy and CLOUDY
  • if a numeric exif value n has no textual representation in exiv2 the returned string is (n) which is pretty much useless so it is discarded now
  • fixed a bug in collection.c where strlen() was used instead of g_utf8_strlen(). This failed on strings containing special characters (e.g. german umlauts)

@zisoft zisoft added the wip pull request in making, tests and feedback needed label Mar 19, 2024
See discussion in darktable-org#16479

It turned out that exiv2 gives a whole zoo of manufacturer specific values for the white balance. In some cases where a camera value has no representation by exiv2, the color temperature value is  returned, in a not well formated way with trailing spaces.

Improvements/fixes:

- remove trailing spaces
- `not defined` and `unknown` are now treated as the darktable default `unnamed`
- entries are now compared case-insensitive before they get written to the database. This avoids having duplicates like `Cloudy` and `CLOUDY`
- if a numeric exif value `n` has no textual representation in exiv2 the returned string is `(n)` which is pretty much useless so it is discarded now
- fixed a bug in `collection.c` where `strlen()` was used instead of `g_utf8_strlen()`. This failed on strings containing special characters (e.g. german umlauts)
@zisoft zisoft removed the wip pull request in making, tests and feedback needed label Mar 19, 2024
Copy link
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor style issues to fix.

One comment, in the description you have:

not defined and unknown are now treated as the darktable default unnamed

Where is this happening? I cannot see this in the code...

src/common/exif.cc Outdated Show resolved Hide resolved
src/common/exif.cc Outdated Show resolved Hide resolved
src/common/exif.cc Outdated Show resolved Hide resolved
@TurboGit TurboGit added this to the 4.8 milestone Mar 19, 2024
@TurboGit TurboGit added bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes scope: DAM managing files, collections, archiving, metadata, etc. scope: codebase making darktable source code easier to manage labels Mar 19, 2024
@zisoft
Copy link
Collaborator Author

zisoft commented Mar 19, 2024

Where is this happening? I cannot see this in the code...

Not defined and unknown are the texts coming from exiv2 if the exif value is 0.
Snippet from the exiv2 source:

//! ExposureProgram, tag 0x8822
constexpr TagDetails exifExposureProgram[] = {
    {0, N_("Not defined")},       {1, N_("Manual")},           {2, N_("Auto")},
    {3, N_("Aperture priority")}, {4, N_("Shutter priority")}, {5, N_("Creative program")},
    {6, N_("Action program")},    {7, N_("Portrait mode")},    {8, N_("Landscape mode")},
};

//! MeteringMode, tag 0x9207
constexpr TagDetails exifMeteringMode[] = {
    {0, N_("Unknown")}, {1, N_("Average")},    {2, N_("Center weighted average")},
    {3, N_("Spot")},    {4, N_("Multi-spot")}, {5, N_("Multi-segment")},
    {6, N_("Partial")}, {255, N_("Other")},    {255, N_("Other")}  // To silence compiler warning
};

So I simply avoid setting the text by checking the exif value. In case of 0 no text is written which is later in the collection filter module handled as unnamed

Copy link
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lot better now, the collection entries are clean. Thanks a lot!

@TurboGit TurboGit merged commit d496f37 into darktable-org:master Mar 19, 2024
6 checks passed
@zisoft zisoft deleted the cleanup-exif branch March 19, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes scope: codebase making darktable source code easier to manage scope: DAM managing files, collections, archiving, metadata, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants