I have a program that controls a camera which takes a capture and send it with MQTT to NodeRed. Here I have a the following package installed: node-red-contrib-image-tools
With this I can show the image and save it in jpg and bmp format and open it... but I need to save several image files with different names...
This is the node configurating that I have:
And finally this is the node where I send the capture to Dashboard:
1 Answer
I have resolved this problem taking the timestamp data and writting a "dynamic name" using this values.
And the code inside the top function block is: `
var now = new Date();
// Create formatted time
var yyyy = now.getFullYear();
var mm = now.getMonth() < 9 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based
var dd = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
var hh = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
var mmm = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
var ss = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
string_1.concat(string_2, string_3);
path = "c:/tfg-sensors-data/photos/" + "photo_num" + msg.count + "-" + yyyy + "-" + mm + "-" + dd + "-" + hh + "-" + mmm + "-" + ss + ".jpg";
msg.filename = path;
return msg;
`