streamlet-examples/exiftool
branchv_0
changeset 71 f8fe085c1c9f
parent 50 22ed5647b235
--- 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 <ExifTool:Error>Unknown file type</ExifTool:Error> 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";