Add TAK mode support to add exif data to incoming TAK messages

This commit is contained in:
Dave Conway-Jones 2025-01-31 15:06:39 +00:00
parent 0b556bade8
commit e4dc4fc81d
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643
4 changed files with 21 additions and 8 deletions

View File

@ -9,6 +9,7 @@
<select style="width:70%" id="node-input-mode">
<option value="normal">Standard node</option>
<option value="worldmap">Use with Worldmap-in node</option>
<option value="tak">Use with TAK Ingest node</option>
</select>
</div>
<div class="form-row" id="node-exif-prop-select">

View File

@ -12,6 +12,7 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.mode = n.mode || "normal";
if (this.mode === "worldmap") { this.property = "payload.content"; }
else if (this.mode === "tak") { this.property = "payload.event.detail.image['#text']"; }
else { this.property = n.property || "payload"; }
var node = this;
var ExifReader = require('exifreader');
@ -81,7 +82,6 @@ module.exports = function(RED) {
else if (node.mode === "worldmap" && (msg.payload.action !== "file" || msg.payload.type.indexOf("image") === -1)) { return; } // in case worldmap-in not filtered.
try {
var value = RED.util.getMessageProperty(msg,node.property);
if (value !== undefined) {
if (typeof value === "string") { // it must be a base64 encoded inline image type
if (value.indexOf('data:image') !== -1) {
@ -91,7 +91,7 @@ module.exports = function(RED) {
value = new Buffer.from(value, 'base64');
}
}
if (Buffer.isBuffer(value)) { // or a proper jpg buffer
if (Buffer.isBuffer(value)) { // or a proper image buffer
msg.exif = ExifReader.load(value);
for (const p in msg.exif) {
if (msg.exif.hasOwnProperty(p)) {
@ -108,6 +108,10 @@ module.exports = function(RED) {
msg.payload = msg.location || {};
delete msg.location;
}
if (node.mode === "tak") {
msg.payload.exif = msg.exif || {};
delete msg.exif;
}
node.send(msg);
}
else {
@ -121,9 +125,15 @@ module.exports = function(RED) {
}
}
catch (error) {
node.error("An error occurred while extracting Exif information. Please check the log for details.",msg);
node.log('Error: '+error.message);
return;
if (node.mode === "tak") {
node.send(msg);
return;
}
else {
node.error("An error occurred while extracting Exif information. Please check the log for details.",msg);
node.log('Error: '+error.message);
return;
}
}
});
}

View File

@ -1,7 +1,7 @@
node-red-node-exif
==================
A <a href="http://nodered.org" target="_new">Node-RED</a> node to extract Exif information from JPEG images.
A <a href="http://nodered.org" target="_new">Node-RED</a> node to extract Exif information from images.
Install
-------
@ -17,7 +17,7 @@ This node now uses the more supported exifreader library so that it handles more
Usage
-----
Extracts <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format">Exif</a> information from JPEG images.
Extracts <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format">Exif</a> information from JPEG or WEBP images.
This node expects an incoming JPEG image as a buffer. If Exif data is present, it extracts the data into a `msg.exif` object.
@ -26,3 +26,5 @@ If the Exif data also contains location information this is extracted as `msg.lo
`msg.payload` retains the original, unmodified image buffer.
You can set it into "worldmap" mode - in this mode the payload contains the "location" data, not the original image, but can be sent directly to a node-red-contrib-worldmap node for visualisation.
Or you can set it into TAK mode - If used with the TAK Ingest node it can extract the exif data from the overall TAK event payload and adds the exif properties to `msg.payload.exif` instead of `msg.exif`.

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-exif",
"version": "1.1.0",
"version": "1.2.0",
"description": "A Node-RED node that extracts Exif information from JPEG image buffers.",
"dependencies": {
"exifreader": "^4.26.1"