mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add dedicated Worldmap mode
better handling of other types
This commit is contained in:
parent
466b1c3deb
commit
c61e8b60b7
@ -1,6 +1,13 @@
|
||||
|
||||
<script type="text/html" data-template-name="exif">
|
||||
<div class="form-row">
|
||||
<label for="node-input-mode"><i class="fa fa-dot-circle-o"></i> Mode</label>
|
||||
<select style="width:70%" id="node-input-mode">
|
||||
<option value="normal">Standard node</option>
|
||||
<option value="worldmap">Use with Worldmap-in node</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row" id="node-exif-prop-select">
|
||||
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label>
|
||||
<input type="text" id="node-input-property" style="width:70%;"/>
|
||||
</div>
|
||||
@ -17,6 +24,8 @@
|
||||
<p>The node then adds location data as <code>msg.location</code>, should the Exif data carry this information.
|
||||
This also includes an icon, bearing and field of view arc suitable for use in the worldmap node.
|
||||
The selected input property retains the original, unmodified image buffer.</p>
|
||||
<p>If configured to use the worldmap in node then the existing image payload will be replaced by the location
|
||||
object so that it can be fed back to the map directly.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -25,6 +34,7 @@
|
||||
color:"#f1c2f0",
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
mode: {value:"normal"},
|
||||
property: {value:"payload",required:true}
|
||||
},
|
||||
inputs:1,
|
||||
@ -39,6 +49,13 @@
|
||||
oneditprepare: function() {
|
||||
if (this.property === undefined) { $("#node-input-property").val("payload"); }
|
||||
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
||||
|
||||
$("#node-input-mode").change(function() {
|
||||
if ($("#node-input-mode").val() === "worldmap") {
|
||||
$("#node-exif-prop-select").hide();
|
||||
}
|
||||
else { $("#node-exif-prop-select").show(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -11,7 +11,9 @@ module.exports = function(RED) {
|
||||
|
||||
function ExifNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.property = n.property || "payload";
|
||||
this.mode = n.mode || "normal";
|
||||
if (this.mode === "worldmap") { this.property = "payload.content"; }
|
||||
else { this.property = n.property || "payload"; }
|
||||
var node = this;
|
||||
|
||||
/***
|
||||
@ -72,10 +74,12 @@ module.exports = function(RED) {
|
||||
else if (msg.hasOwnProperty("filename")) { na = msg.filename.split('/').pop(); }
|
||||
else { na = msg.exif.image.Make+"_"+msg.exif.image.ModifyDate; }
|
||||
msg.location.name = na;
|
||||
msg.location.layer = "Images";
|
||||
msg.location.popup = '<img width="280" src="data:image/jpeg;base64,'+val.toString("base64")+'"/>'
|
||||
}
|
||||
|
||||
this.on("input", function(msg) {
|
||||
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) {
|
||||
@ -87,7 +91,13 @@ module.exports = function(RED) {
|
||||
if (Buffer.isBuffer(value)) { // or a proper jpg buffer
|
||||
new ExifImage({ image:value }, function (error, exifData) {
|
||||
if (error) {
|
||||
node.log(error.toString());
|
||||
if (node.mode !== "worldmap") {
|
||||
node.log(error.toString());
|
||||
}
|
||||
else {
|
||||
msg.location = {name:msg.payload.name, lat:msg.payload.lat, lon:msg.payload.lon, layer:"Images", icon:"fa-camera", draggable:true};
|
||||
msg.location.popup = '<img width="280" src="data:image\/png;base64,'+msg.payload.content.toString('base64')+'"/><br/>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (exifData) {
|
||||
@ -101,6 +111,10 @@ module.exports = function(RED) {
|
||||
node.warn("The incoming image did not contain any Exif data, nothing to do.");
|
||||
}
|
||||
}
|
||||
if (node.mode === "worldmap") {
|
||||
msg.payload = msg.location;
|
||||
delete msg.location;
|
||||
}
|
||||
node.send(msg);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-node-exif",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "A Node-RED node that extracts Exif information from JPEG image buffers.",
|
||||
"dependencies": {
|
||||
"exif": "^0.6.0"
|
||||
|
Loading…
Reference in New Issue
Block a user