mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Add TAK mode support to add exif data to incoming TAK messages
This commit is contained in:
parent
0b556bade8
commit
e4dc4fc81d
@ -9,6 +9,7 @@
|
|||||||
<select style="width:70%" id="node-input-mode">
|
<select style="width:70%" id="node-input-mode">
|
||||||
<option value="normal">Standard node</option>
|
<option value="normal">Standard node</option>
|
||||||
<option value="worldmap">Use with Worldmap-in node</option>
|
<option value="worldmap">Use with Worldmap-in node</option>
|
||||||
|
<option value="tak">Use with TAK Ingest node</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row" id="node-exif-prop-select">
|
<div class="form-row" id="node-exif-prop-select">
|
||||||
|
@ -12,6 +12,7 @@ module.exports = function(RED) {
|
|||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.mode = n.mode || "normal";
|
this.mode = n.mode || "normal";
|
||||||
if (this.mode === "worldmap") { this.property = "payload.content"; }
|
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"; }
|
else { this.property = n.property || "payload"; }
|
||||||
var node = this;
|
var node = this;
|
||||||
var ExifReader = require('exifreader');
|
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.
|
else if (node.mode === "worldmap" && (msg.payload.action !== "file" || msg.payload.type.indexOf("image") === -1)) { return; } // in case worldmap-in not filtered.
|
||||||
try {
|
try {
|
||||||
var value = RED.util.getMessageProperty(msg,node.property);
|
var value = RED.util.getMessageProperty(msg,node.property);
|
||||||
|
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if (typeof value === "string") { // it must be a base64 encoded inline image type
|
if (typeof value === "string") { // it must be a base64 encoded inline image type
|
||||||
if (value.indexOf('data:image') !== -1) {
|
if (value.indexOf('data:image') !== -1) {
|
||||||
@ -91,7 +91,7 @@ module.exports = function(RED) {
|
|||||||
value = new Buffer.from(value, 'base64');
|
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);
|
msg.exif = ExifReader.load(value);
|
||||||
for (const p in msg.exif) {
|
for (const p in msg.exif) {
|
||||||
if (msg.exif.hasOwnProperty(p)) {
|
if (msg.exif.hasOwnProperty(p)) {
|
||||||
@ -108,6 +108,10 @@ module.exports = function(RED) {
|
|||||||
msg.payload = msg.location || {};
|
msg.payload = msg.location || {};
|
||||||
delete msg.location;
|
delete msg.location;
|
||||||
}
|
}
|
||||||
|
if (node.mode === "tak") {
|
||||||
|
msg.payload.exif = msg.exif || {};
|
||||||
|
delete msg.exif;
|
||||||
|
}
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -121,9 +125,15 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
node.error("An error occurred while extracting Exif information. Please check the log for details.",msg);
|
if (node.mode === "tak") {
|
||||||
node.log('Error: '+error.message);
|
node.send(msg);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
node.error("An error occurred while extracting Exif information. Please check the log for details.",msg);
|
||||||
|
node.log('Error: '+error.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
node-red-node-exif
|
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
|
Install
|
||||||
-------
|
-------
|
||||||
@ -17,7 +17,7 @@ This node now uses the more supported exifreader library so that it handles more
|
|||||||
Usage
|
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.
|
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.
|
`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.
|
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`.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-node-exif",
|
"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.",
|
"description": "A Node-RED node that extracts Exif information from JPEG image buffers.",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"exifreader": "^4.26.1"
|
"exifreader": "^4.26.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user