node-red-contrib-hikvision-ultimate
Advanced tools
Comparing version
@@ -5,2 +5,6 @@ # node-red-contrib-hikvision-ultimate | ||
<p> | ||
<b>Version 1.0.7</b> December 2020<br/> | ||
- NEW: Picture node, you can now set the output quality, from 10 to 100.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.6</b> December 2020<br/> | ||
@@ -7,0 +11,0 @@ - Increased timeout for situation where the connection is via VPN or very slow. Thanks @Georg for suggesting this thing.<br/> |
module.exports = function (RED) { | ||
const sharp = require("sharp"); // Resize | ||
const jimp = require("jimp"); // Resize | ||
@@ -15,2 +15,3 @@ function hikvisionUltimatePicture(config) { | ||
node.widthimage = (config.widthimage === null || config.widthimage === undefined || config.rotateimage.trim() === "") ? "0" : config.widthimage; | ||
node.qualityimage = (config.qualityimage === null || config.qualityimage === undefined || config.qualityimage.trim() === "") ? "80" : config.qualityimage; | ||
@@ -39,23 +40,22 @@ node.setNodeStatus = ({ fill, shape, text }) => { | ||
try { | ||
var msg_payload = sharp(_msg.payload); | ||
if (node.rotateimage !== 0) msg_payload = msg_payload.rotate(Number(node.rotateimage)); | ||
if (node.heightimage !== "0" && node.widthimage !== "0") msg_payload = msg_payload.resize(Number(node.widthimage), Number(node.heightimage)); | ||
msg_payload.toBuffer().then(picture => { | ||
_msg.payload = "data:image/jpg;base64," + picture.toString("base64"); | ||
node.send(_msg, null); | ||
node.setNodeStatus({ fill: "green", shape: "dot", text: "Picture received" }); | ||
}).catch(err => { }); | ||
jimp.read(_msg.payload) | ||
.then(image => { | ||
if (node.rotateimage !== 0) image = image.rotate(Number(node.rotateimage)); | ||
if (node.heightimage !== "0" && node.widthimage !== "0") image = image.resize(Number(node.widthimage), Number(node.heightimage)); | ||
image = image.quality(Number(node.qualityimage)); | ||
image.getBufferAsync(jimp.MIME_JPEG).then(picture => { | ||
_msg.payload = "data:image/jpg;base64," + picture.toString("base64"); | ||
node.send(_msg, null); | ||
node.setNodeStatus({ fill: "green", shape: "dot", text: "Picture received" }); | ||
}).catch(error => { | ||
node.setNodeStatus({ fill: "red", shape: "dot", text: "GetBuffer error: " + error.message }); | ||
}); | ||
}); | ||
} catch (error) { | ||
node.setNodeStatus({ fill: "red", shape: "dot", text: "Image error: " + error.message }); | ||
} | ||
// sharp(_msg.payload).rotate().resize(4000, 3000).toBuffer().then(picture => { | ||
// _msg.payload = picture.toString("base64"); | ||
// node.send(_msg, null); | ||
// node.setNodeStatus({ fill: "green", shape: "dot", text: "Picture received" }); | ||
// }).catch(err => { }); | ||
} | ||
@@ -62,0 +62,0 @@ |
{ | ||
"name": "node-red-contrib-hikvision-ultimate", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A native set of node for Hikvision Cameras, Alarms, Radars etc.", | ||
@@ -12,3 +12,3 @@ "author": "Supergiovane (https://github.com/Supergiovane)", | ||
"util": ">=0.12.3", | ||
"sharp": "0.26.3" | ||
"jimp": "0.16.1" | ||
}, | ||
@@ -15,0 +15,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
664400
0.12%933
0.21%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed