# HG changeset patch # User František Kučera # Date 1580298043 -3600 # Node ID f8fe085c1c9fbe24e8ca71efec40df14505a7423 # Parent 018e2609f5bbdca6f08b6bae6d74f0fba2530c4d streamlet examples: exiftool: integer data type for certain attributes diff -r 018e2609f5bb -r f8fe085c1c9f streamlet-examples/exiftool --- a/streamlet-examples/exiftool Wed Jan 29 00:58:37 2020 +0100 +++ b/streamlet-examples/exiftool Wed Jan 29 12:40:43 2020 +0100 @@ -45,8 +45,11 @@ fi for (( i=0; i<${#streamletFields[@]}; i++)); do - # TODO: data type mappings (integers, booleans) - send OUTPUT_ATTRIBUTE_METADATA "${outputAttributeAliases[$i]-$pdfPrefix${streamletFields[$i]}}" "string" + local exifIntegerFields="^(PNG:ImageWidth|PNG:ImageHeight|PNG:BitDepth|File:ImageWidth|File:ImageHeight|File:BitsPerSample|File:ColorComponents)$"; + if [[ "${streamletFields[$i]}" =~ "$exifIntegerFields" ]]; then type="integer"; + else type="string"; + fi + send OUTPUT_ATTRIBUTE_METADATA "${outputAttributeAliases[$i]-$pdfPrefix${streamletFields[$i]}}" "$type" done send WAITING_FOR_INPUT_ATTRIBUTES @@ -70,8 +73,8 @@ fi # n.b. for some files exiftools returns exit code, however it provides some basic properties like file timestamps and Unknown file type which is also valid XML and might be useful - if [[ ! "x$streamletValid" == "x0" ]] && [[ "x$value" == "x" ]]; then value=""; isNull="true"; - else isNull="false"; + if [[ ! "x$streamletValid" == "x0" ]] || [[ "x$value" == "x" ]]; then isNull="true"; + else isNull="false"; fi send OUTPUT_ATTRIBUTE "$value" "$isNull";