Reading Images from one folder into one array

Hi Guys,

I am still new to node-red so I try to figure out some basic stuff.
This time I stumbled over something within the node-red-contrib-animate-gif node.
The Info tab for the Input Data says:
array of image buffers to use as GIF frames.

I have all files stored in one single folder, which is updated from time to time by a snapshot from a web-cam. So I am not 100% sure how I may utilize this gif-node in an practicable way for me.
One thing I thought about: I have to extract all images files via js in a function block and put everything together into a image buffer array.
But maybe there is again some build-in function I just do not know yet, which would save me enourmous time in solving that problem, since I am also new to scipting in js.

Thanks already in advance,
cheers Christian

Hi Christian,

First of all: I hope you are aware that storing webcam images in an array will consume much RAM memory. Not sure whether you are talking about large images or a lot of images?

Indeed you could do all of that in a function node. I had a quick look and I don't think there is currently a node available that can read the content of all files of a folder into an array.

The closest thing I found is the File-Lister node, which is part of the node-red-contrib-fs from @TotallyInformation. I'm not sure whether it might be a good idea to ask him to add an extra checkbox to this node:

Which would trigger a small code snippet:

Of course, this way the default encoding will be used all of the time ...


Yes, file lister will give you the files to work with, you can then send each to a file-in node then to a variable.

However, as you say, that's potentially a LOT of memory. It would be far better to use a command line tool to directly create the gif because that will most likely be written in C++ or go (maybe rust) and so be very memory efficient. JavaScript isn't a good language for that.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.