Aller au contenu principal
Version: 4.3

Attributes initial values

1: Check of integration "metadata-read"​

Extracting the ExifTool:ExifToolVersion metadata allows to ensure that the metadata-read. integration is functional. The metadata ExifTool:ExifToolVersion in always returned by exiftool.

Attribute(s) definition(s) ...​

  • exiftoolVersion: text ; [ ] multi ; [ ] translatable

    • read from metadata (first found wins):
    [
    "ExifTool:ExifToolVersion"
    ]

... with file metadata ...​

metadatavalue(s)
ExifTool:ExifToolVersion13.59

... set attribute(s) initial value(s)​

Attributesinitial value(s)
exiftoolVersion13.59

2: Multi-values metadata -> mono-value attribute (readFromMetadata)​

Values will be separated by " ; "

Attribute(s) definition(s) ...​

  • Keywords: text ; [ ] multi ; [ ] translatable

    • read from metadata (first found wins):
    [
    "IPTC:Keywords"
    ]

... with file metadata ...​

metadatavalue(s)
IPTC:Keywordsdog ; cat ; bird

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Keywordsdog ; cat ; bird

3: Multi-values metadata -> multi-values attribute (readFromMetadata)​

Attribute(s) definition(s) ...​

  • Keywords: text ; [X] multi ; [ ] translatable

    • read from metadata (first found wins):
    [
    "IPTC:Keywords"
    ]

... with file metadata ...​

metadatavalue(s)
IPTC:Keywordsdog ; cat ; bird

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Keywords #1dog
Keywords #2cat
Keywords #3bird

4: Multi-values metadata -> multi-values attribute ("template" method)​

warning : Wrong usage of getMetadata(...).value (without "s")

Attribute(s) definition(s) ...​

  • Keywords: text ; [X] multi ; [ ] translatable
{{ file.getMetadata('IPTC:Keywords').value }}

... with file metadata ...​

metadatavalue(s)
IPTC:Keywordsdog ; cat ; bird

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Keywordsdog ; cat ; bird

5: Multi-values metadata -> multi-values attribute ("template" method)​

Good usage of getMetadata(...).values

Attribute(s) definition(s) ...​

  • Keywords: text ; [X] multi ; [ ] translatable
{{ file.getMetadata('IPTC:Keywords').values | join("\n") }}

... with file metadata ...​

metadatavalue(s)
IPTC:Keywordsdog ; cat ; bird

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Keywords #1dog
Keywords #2cat
Keywords #3bird

6: Mono-value multilocale​

Attribute(s) definition(s) ...​

  • Copyright: text ; [ ] multi ; [ ] translatable

    • locale en
    (c) {{ file.getMetadata('XMP-dc:Creator').value }}. All rights reserved
    • locale fr
    (c) {{ file.getMetadata('XMP-dc:Creator').value }}. Tous droits réservés

... with file metadata ...​

metadatavalue(s)
XMP-dc:CreatorBob

... set attribute(s) initial value(s)​

Attributesinitial value(s)
locale en
Copyright(c) Bob. All rights reserved
locale fr
Copyright(c) Bob. Tous droits réservés

7: Multi-values multilocale​

Attribute(s) definition(s) ...​

  • Keywords: text ; [X] multi ; [ ] translatable

    • locale en
    {{ file.getMetadata('XMP-dc:Subject').values | join("\n") }}
    • locale fr
    {{ file.getMetadata('IPTC:SupplementalCategories').values | join("\n") }}

... with file metadata ...​

metadatavalue(s)
XMP-dc:Subjectdog ; cat ; bird
IPTC:SupplementalCategorieschien ; chat ; oiseau

... set attribute(s) initial value(s)​

Attributesinitial value(s)
locale en
Keywords #1dog
Keywords #2cat
Keywords #3bird
locale fr
Keywords #1chien
Keywords #2chat
Keywords #3oiseau

8: Unknown tag​

Attribute(s) definition(s) ...​

  • zAttribute: text ; [ ] multi ; [ ] translatable
{{ (file.getMetadata('badTag').value ?? 'whaat ?') }}

... with file metadata ...​

metadatavalue(s)

... set attribute(s) initial value(s)​

Attributesinitial value(s)
zAttributewhaat ?

9: First metadata set, with alternate value (1)​

for this test, only the metadata IPTC:City is set.

Attribute(s) definition(s) ...​

  • City: text ; [ ] multi ; [ ] translatable
{{ file.getMetadata('XMP-iptcCore:CreatorCity').value ?? file.getMetadata('IPTC:City').value ?? 'no-city ?' }}

... with file metadata ...​

metadatavalue(s)
IPTC:CityParis

... set attribute(s) initial value(s)​

Attributesinitial value(s)
CityParis

10: First metadata set, with alternate value (2)​

for this test, no metadata is set, so the default value is used.

Attribute(s) definition(s) ...​

  • City: text ; [ ] multi ; [ ] translatable
{{ file.getMetadata('XMP-iptcCore:CreatorCity').value ?? file.getMetadata('IPTC:City').value ?? 'no-city ?' }}

... with file metadata ...​

metadatavalue(s)

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Cityno-city ?

11: Many metadata to a mono-value attribute​

Here an array [a, b] is used, the join filter inserts a " - " only if required.

Attribute(s) definition(s) ...​

  • CreatorLocation: text ; [ ] multi ; [ ] translatable
{{ [file.getMetadata('XMP-iptcCore:CreatorCity').value, file.getMetadata('XMP-iptcCore:CreatorCountry').value] | join(' - ') }}

... with file metadata ...​

metadatavalue(s)
XMP-iptcCore:CreatorCityParis
XMP-iptcCore:CreatorCountryFrance

... set attribute(s) initial value(s)​

Attributesinitial value(s)
CreatorLocationParis - France

12: Many metadata to a multi-values attribute​

nb: We fill an array that will be joined by \n to generate one line per item (required).

The merge filter requires arrays, so IPTC:Keywords defaults to [] in case there is no keywords in metadata.

Attribute(s) definition(s) ...​

  • Keywords: text ; [X] multi ; [ ] translatable
{{ ( (file.getMetadata('IPTC:Keywords').values ?? []) | merge([file.getMetadata('IPTC:City').value, file.getMetadata('XMP-photoshop:Country').value ]) ) | join("\n") }}

... with file metadata ...​

metadatavalue(s)
IPTC:KeywordsEiffel Tower ; Seine river
IPTC:CityParis
XMP-photoshop:CountryFrance

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Keywords #1Eiffel Tower
Keywords #2Seine river
Keywords #3Paris
Keywords #4France

13: Transform code to human readable text​

here the ExposureProgram metadata is a code (0...9), used to index an array of strings.

Attribute(s) definition(s) ...​

  • ExposureProgram: text ; [ ] multi ; [ ] translatable
{{ [ 'Not Defined', 'Manual', 'Program AE', 'Aperture-priority AE', 'Shutter speed priority AE', 'Creative (Slow speed)', 'Action (High speed)', 'Portrait', 'Landscape',  'Bulb' ][file.getMetadata('ExifIFD:ExposureProgram').value] ?? 'Unknown mode' }}

... with file metadata ...​

metadatavalue(s)
ExifIFD:ExposureProgram2

... set attribute(s) initial value(s)​

Attributesinitial value(s)
ExposureProgramProgram AE

14: Read from metadata: first tag found wins​

The readFromMetadata list is evaluated in order; the first tag present in the file metadata is used. Here XMP-iptcCore:CreatorCity is absent, so IPTC:City is used.

Attribute(s) definition(s) ...​

  • City: text ; [ ] multi ; [ ] translatable

    • read from metadata (first found wins):
    [
    "XMP-iptcCore:CreatorCity",
    "IPTC:City"
    ]

... with file metadata ...​

metadatavalue(s)
IPTC:CityParis

... set attribute(s) initial value(s)​

Attributesinitial value(s)
CityParis

15: Read from metadata into a multi-values attribute​

Attribute(s) definition(s) ...​

  • Keywords: text ; [X] multi ; [ ] translatable

    • read from metadata (first found wins):
    [
    "XMP-dc:Subject",
    "IPTC:Keywords"
    ]

... with file metadata ...​

metadatavalue(s)
IPTC:Keywordsdog ; cat ; bird

... set attribute(s) initial value(s)​

Attributesinitial value(s)
Keywords #1dog
Keywords #2cat
Keywords #3bird

16: Read from metadata: no tag found​

When none of the listed tags is present, no attribute is created.

Attribute(s) definition(s) ...​

  • City: text ; [ ] multi ; [ ] translatable

    • read from metadata (first found wins):
    [
    "XMP-iptcCore:CreatorCity",
    "IPTC:City"
    ]

... with file metadata ...​

metadatavalue(s)

... set attribute(s) initial value(s)​

Attributesinitial value(s)