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

exiftool "ColorMode" and "ColorSpaceData" are passed through un-normalized, despite being invalid values #83

Open
LeoniePhiline opened this issue Mar 21, 2024 · 0 comments

Comments

@LeoniePhiline
Copy link
Contributor

exiftool -j may extract "ColorMode" and "ColorSpaceData" values which are not fit to be placed into sys_file_metadata.color_space unaltered.

Example:

exiftool -j "exampe-sRGB-black-and-white-file.jpg" \
    | jq '[.[] | {ColorMode, ColorSpaceData, ColorSpace}]' 
[
  {
    "ColorMode": "Grayscale",
    "ColorSpaceData": "GRAY",
    "ColorSpace": "sRGB"
  }
]

extractor defines color_space mapping as follows:

jq '.[] | select(.FAL == "color_space")' "extractor/Configuration/Services/ExifTool/default.json"
{
  "FAL": "color_space",
  "DATA": [
    "ColorMode",
    "ColorSpaceData",
    "ColorSpace->Causal\\Extractor\\Utility\\ColorSpace::normalize"
  ]
}

Since \Causal\Extractor\Service\Extraction\AbstractExtractionService::remapServiceOutput breaks upon a non-null $value, the exiftool value "ColorMode" = "Grayscale" is extracted and passed back to the TYPO3 metadata extraction service, where it is used as parameter for an INSERT INTO sys_file_metadata.

However, the sys_file_metadata.color_space field is a VARCHAR(4), and "Grayscale" does not fit, causing an error in strict mode.

Furthermore, "Grayscale" is an invalid value. According to SYSEXT:filemetadata/Configuration/TCA/Overrides/sys_file_metadata.php, the correct grayscale color_space value would be "grey".

Thus, ColorMode = "Grayscale" and ColorSpaceData = "GRAY" must be normalized to the value "grey".

To my mind, this should be handled by the ColorSpace utility, using a configuration like ...:

{
  "FAL": "color_space",
  "DATA": [
    "ColorMode->Causal\\Extractor\\Utility\\ColorSpace::normalize",
    "ColorSpaceData->Causal\\Extractor\\Utility\\ColorSpace::normalize",
    "ColorSpace->Causal\\Extractor\\Utility\\ColorSpace::normalize"
  ]
}

... and adjusting Causal\Extractor\Utility\ColorSpace::normalize to match on strings starting (lowercased) with "gray" or "grey" and replacing them with the canonical "grey" value.

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

No branches or pull requests

1 participant