1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
* Fix for #813

Ensure `msg.location` exists before populating

* Only add location data if location present
This commit is contained in:
Ben Hardill 2021-06-29 09:03:46 +01:00 committed by GitHub
parent cdcafbad1d
commit ebd043cec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -62,20 +62,22 @@ module.exports = function(RED) {
else { else {
node.log("The location of this image cannot be determined safely so no location information has been added to the message."); node.log("The location of this image cannot be determined safely so no location information has been added to the message.");
} }
msg.location.arc = { if (msg.location) {
ranges: [500,1000,2000], msg.location.arc = {
pan: gpsData.GPSImgDirection, ranges: [500,1000,2000],
fov: (2 * Math.atan(36 / (2 * msg.exif.exif.FocalLengthIn35mmFormat)) * 180 / Math.PI), pan: gpsData.GPSImgDirection,
color: '#910000' fov: (2 * Math.atan(36 / (2 * msg.exif.exif.FocalLengthIn35mmFormat)) * 180 / Math.PI),
color: '#910000'
}
msg.location.icon = "fa-camera";
var na;
if (val.hasOwnProperty("name")) { na = val.name; }
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")+'"/>'
} }
msg.location.icon = "fa-camera";
var na;
if (val.hasOwnProperty("name")) { na = val.name; }
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) { this.on("input", function(msg) {

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-node-exif", "name": "node-red-node-exif",
"version": "0.2.1", "version": "0.2.2",
"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": {
"exif": "^0.6.0" "exif": "^0.6.0"