New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-hikvision-ultimate

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-hikvision-ultimate - npm Package Compare versions

Comparing version 1.0.26 to 1.0.27

4

CHANGELOG.md

@@ -7,2 +7,6 @@ <p align="center"><img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-hikvision-ultimate/master/img/logo.png' width="40%"></p>

<p>
<b>Version 1.0.27</b> January 2021<br/>
- NEW: Text overlay in the picture node. You can also set the position and font. The text can be set with msg.textoverlay as well.<br/>
</p>
<p>
<b>Version 1.0.26</b> January 2021<br/>

@@ -9,0 +13,0 @@ - Fixed an unwanted LOG in case you have a picture node asking for an image to an unconnected camera.<br/>

139

nodes/hikvisionUltimatePicture.js

@@ -15,2 +15,3 @@

node.pictureAltezza = 0;
node.textoverlay = (config.textoverlay === null || config.textoverlay === undefined || config.textoverlay.trim() === "") ? "" : config.textoverlay;

@@ -30,2 +31,8 @@ node.setNodeStatus = ({ fill, shape, text }) => {

node.cropimage = (_config.cropimage === null || _config.cropimage === undefined || _config.cropimage.trim() === "") ? "" : _config.cropimage;
// 27/01/2021 Fonts
//node.textoverlay = (_config.textoverlay === null || _config.textoverlay === undefined || _config.textoverlay.trim() === "") ? "" : _config.textoverlay;
node.textoverlayXY = (_config.textoverlayXY === null || _config.textoverlayXY === undefined || _config.textoverlayXY.trim() === "") ? "0,0" : _config.textoverlayXY;
node.textoverlayWH = (_config.textoverlayWH === null || _config.textoverlayWH === undefined || _config.textoverlayWH.trim() === "") ? "" : _config.textoverlayWH;
node.textoverlayFont = (_config.textoverlayFont === null || _config.textoverlayFont === undefined || _config.textoverlayFont.trim() === "") ? "FONT_SANS_32_WHITE" : _config.textoverlayFont;
if (node.cropimage !== "" && node.cropimage.split(",").length === 4) {

@@ -41,2 +48,20 @@ node.cropimage = {

}
if (node.textoverlayXY !== "" && node.textoverlayXY.split(",").length === 2) {
node.textoverlayXY = {
x: Number(node.textoverlayXY.split(",")[0].trim()),
y: Number(node.textoverlayXY.split(",")[1].trim())
}
} else {
node.textoverlayXY = "";
}
if (node.textoverlayWH !== "" && node.textoverlayWH.split(",").length === 2) {
node.textoverlayWH = {
w: Number(node.textoverlayWH.split(",")[0].trim()),
h: Number(node.textoverlayWH.split(",")[1].trim())
}
} else {
node.textoverlayWH = "";
}
}

@@ -52,14 +77,23 @@ node.variabilizeManipulation(config);

// var sManipulate = $("#node-input-channelID").val();
// sManipulate += "SEP" + $("#node-input-qualityimage").val();
// sManipulate += "SEP" + $("#node-input-rotateimage").val();
// sManipulate += "SEP" + $("#node-input-widthimage").val();
// sManipulate += "SEP" + $("#node-input-heightimage").val();
// sManipulate += "SEP" + $("#node-input-cropimage").val().toString().trim().replace(/\s/g, '').replace(/,/g,"-");
// sManipulate += "-SEP-" + $("#node-input-qualityimage").val();
// sManipulate += "-SEP-" + $("#node-input-rotateimage").val();
// sManipulate += "-SEP-" + $("#node-input-widthimage").val();
// sManipulate += "-SEP-" + $("#node-input-heightimage").val();
// sManipulate += "S-SEP-EP" + $("#node-input-cropimage").val().toString().trim().replace(/\s/g, '').replace(/,/g, "-");
// sManipulate += "-SEP-" + $("#node-input-textoverlay").val();
// sManipulate += "-SEP-" + $("#node-input-textoverlayXY").val().toString().trim().replace(/\s/g, '').replace(/,/g, "-");
// sManipulate += "-SEP-" + $("#node-input-textoverlayWH").val().toString().trim().replace(/\s/g, '').replace(/,/g, "-");
// sManipulate += "-SEP-" + $("#node-input-textoverlayFont").val();
var sManipulate = req.query.manipulate;
var oConfig = { channelID: sManipulate.split("SEP")[0].toString().trim() };
oConfig.qualityimage = sManipulate.split("SEP")[1].toString().trim();
oConfig.rotateimage = sManipulate.split("SEP")[2].toString().trim();
oConfig.widthimage = sManipulate.split("SEP")[3].toString().trim();
oConfig.heightimage = sManipulate.split("SEP")[4].toString().trim();
oConfig.cropimage = sManipulate.split("SEP")[5].toString().trim().replace(/-/g, ",");
var oConfig = { channelID: sManipulate.split("-SEP-")[0].toString().trim() };
oConfig.qualityimage = sManipulate.split("-SEP-")[1].toString().trim();
oConfig.rotateimage = sManipulate.split("-SEP-")[2].toString().trim();
oConfig.widthimage = sManipulate.split("-SEP-")[3].toString().trim();
oConfig.heightimage = sManipulate.split("-SEP-")[4].toString().trim();
oConfig.cropimage = sManipulate.split("-SEP-")[5].toString().trim().replace(/-/g, ",");
oConfig.textoverlay = sManipulate.split("-SEP-")[6].toString().trim();
oConfig.textoverlayXY = sManipulate.split("-SEP-")[7].toString().trim().replace(/-/g, ",");
oConfig.textoverlayWH = sManipulate.split("-SEP-")[8].toString().trim().replace(/-/g, ",");
oConfig.textoverlayFont = sManipulate.split("-SEP-")[9].toString().trim();
node.variabilizeManipulation(oConfig);

@@ -100,23 +134,66 @@ //#endregion

// Get picture
node.getPicture = (_picBase64) => new Promise(function (resolve, reject) {
// node.getPicture = (_picBase64) => new Promise(function (resolve, reject) {
// try {
// jimp.read(_picBase64)
// .then(image => {
// if (node.rotateimage !== 0) image = image.rotate(Number(node.rotateimage));
// if (node.cropimage !== "") image = image.crop(node.cropimage.x, node.cropimage.y, node.cropimage.w, node.cropimage.h);
// if (node.heightimage !== "0" && node.widthimage !== "0") image = image.resize(Number(node.widthimage), Number(node.heightimage));
// if (node.qualityimage !== 100) image = image.quality(Number(node.qualityimage));
// node.pictureLarghezza = image.bitmap.width;
// node.pictureAltezza = image.bitmap.height;
// jimp.loadFont(jimp.FONT_SANS_32_WHITE).then(font => {
// image = image.print(font, 10, 10, 'Hello World!');
// }).catch(err => { });
// image.getBufferAsync(jimp.MIME_JPEG).then(picture => {
// node.picture = "data:image/jpg;base64," + picture.toString("base64");
// resolve(node.picture);
// }).catch(error => {
// reject(error);
// });
// });
// } catch (error) {
// reject(error);
// }
// });
// Get picture
async function getPicture(_picBase64) {
try {
jimp.read(_picBase64)
.then(image => {
if (node.rotateimage !== 0) image = image.rotate(Number(node.rotateimage));
if (node.cropimage !== "") image = image.crop(node.cropimage.x, node.cropimage.y, node.cropimage.w, node.cropimage.h);
if (node.heightimage !== "0" && node.widthimage !== "0") image = image.resize(Number(node.widthimage), Number(node.heightimage));
if (node.qualityimage !== 100) image = image.quality(Number(node.qualityimage));
node.pictureLarghezza = image.bitmap.width;
node.pictureAltezza = image.bitmap.height;
image.getBufferAsync(jimp.MIME_JPEG).then(picture => {
node.picture = "data:image/jpg;base64," + picture.toString("base64");
resolve(node.picture);
}).catch(error => {
reject(error);
image = await jimp.read(_picBase64);
if (node.rotateimage !== 0) image = await image.rotate(Number(node.rotateimage));
if (node.cropimage !== "") image = await image.crop(node.cropimage.x, node.cropimage.y, node.cropimage.w, node.cropimage.h);
if (node.heightimage !== "0" && node.widthimage !== "0") image = await image.resize(Number(node.widthimage), Number(node.heightimage));
if (node.qualityimage !== 100) image = await image.quality(Number(node.qualityimage));
node.pictureLarghezza = image.bitmap.width;
node.pictureAltezza = image.bitmap.height;
// 27/01/2021 FONTS
if (node.textoverlay !== "") {
const oFont = jimp[node.textoverlayFont];
const font = await jimp.loadFont(oFont);
if (node.textoverlayWH === "") {
image = await image.print(font, node.textoverlayXY.x, node.textoverlayXY.y, {
text: node.textoverlay,
alignmentX: jimp.HORIZONTAL_ALIGN_LEFT,
alignmentY: jimp.VERTICAL_ALIGN_TOP
});
});
} else {
image = await image.print(font, node.textoverlayXY.x, node.textoverlayXY.y, {
text: node.textoverlay,
alignmentX: jimp.HORIZONTAL_ALIGN_LEFT,
alignmentY: jimp.VERTICAL_ALIGN_TOP
}, node.textoverlayWH.w, node.textoverlayWH.h);
}
}
let picture = await image.getBufferAsync(jimp.MIME_JPEG);
node.picture = "data:image/jpg;base64," + picture.toString("base64");
return (node.picture);
} catch (error) {
reject(error);
return (error);
}
});
};

@@ -142,3 +219,3 @@

node.getPicture(_msg.payload).then(data => {
getPicture(_msg.payload).then(data => {
_msg.payload = data;

@@ -162,6 +239,6 @@ node.send(_msg, null);

if (msg === null || msg === undefined) return;
if (msg.hasOwnProperty("textoverlay")) node.textoverlay = msg.textoverlay;
if (msg.hasOwnProperty("payload") && msg.hasOwnProperty("payload") !== null && msg.hasOwnProperty("payload") !== undefined) {
if (msg.payload === true) {
// Recall PTZ Preset
// Params: _callerNode, _method, _URL, _body
try {

@@ -168,0 +245,0 @@ // Call the request, that then sends the result via node.sendPayload function

{
"name": "node-red-contrib-hikvision-ultimate",
"version": "1.0.26",
"version": "1.0.27",
"description": "A native set of nodes for Hikvision Cameras, Alarms, Radars etc.",

@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)",

@@ -169,3 +169,3 @@

```
The ***Dashboard*** node in this example, contains this code:
The ***Dashboard*** node in this example, is a **UI_TEMPLATE** and contains this code:
```javascript

@@ -183,5 +183,13 @@ <div ng-bind-html="msg.payload"></div>

```javascript
msg.payload = true; // To get the image
// To get the image
msg.payload = true;
```
```javascript
// Dinamically set the overlay text
node.textoverlay = "Hello new overlay";
msg.payload = true;
```
**Output PIN 1**

@@ -188,0 +196,0 @@ ```javascript

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc