# Reading Images from one folder into one array

**URL:** https://discourse.nodered.org/t/reading-images-from-one-folder-into-one-array/40127
**Category:** General
**Created:** [31 January 2021 18:48 UTC](https://discourse.nodered.org/t/reading-images-from-one-folder-into-one-array/40127 "2021-01-31T18:48:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ChristianM](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christianm/32/36266_2.png) [@ChristianM](https://discourse.nodered.org/u/ChristianM)
#### Post date: [31 January 2021 18:48 UTC](https://discourse.nodered.org/t/reading-images-from-one-folder-into-one-array/40127/1 "2021-01-31T18:48:15Z")

</div>

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:  
**payloadarray**  
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

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [31 January 2021 21:49 UTC](https://discourse.nodered.org/t/reading-images-from-one-folder-into-one-array/40127/2 "2021-01-31T21:49:44Z")

</div>

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](https://github.com/totallyinformation/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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/82b10d8091180cf66b4069e1f0503074b6a3fc42.png)

Which would trigger a small code snippet:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb8906fc6a29ca65449bfcce0c1a4cec58cd3244.png)

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

Bart

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [1 February 2021 21:28 UTC](https://discourse.nodered.org/t/reading-images-from-one-folder-into-one-array/40127/3 "2021-02-01T21:28:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [2 April 2021 21:29 UTC](https://discourse.nodered.org/t/reading-images-from-one-folder-into-one-array/40127/4 "2021-04-02T21:29:14Z")

</div>

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