# Loading large amount of image files

**URL:** <https://discourse.processing.org/t/loading-large-amount-of-image-files/23971>\
**Category:** Coding Questions\
**Created:** [September 19, 2020, 10:37pm UTC](https://discourse.processing.org/t/loading-large-amount-of-image-files/23971 "2020-09-19T22:37:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 20, 2020, 5:16am UTC](https://discourse.processing.org/t/loading-large-amount-of-image-files/23971/2 "2020-09-20T05:16:49Z")

</div>

> [@paulgoux](#):
>
> , then saving the loaded image into an array…

If Java can’t allocate that much RAM don’t load everything at once!

Instead collect all paths via [**listPaths()**](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#listPaths-java.lang.String-java.lang.String...-), then **loadImage()** + **resize()** + **save()** 1 by 1 inside a loop:

> [@File Listing Order](https://discourse.processing.org/t/file-listing-order/7148/41):
>
> [Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#sort(java.lang.Object[])](http://Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#sort(java.lang.Object%5B%5D)) static final String PICS\_EXTS = "extensions=,png,jpg,jpeg,gif,tif,tiff,tga,bmp,wbmp"; static final float FPS = .25; PImage[] images; void setup() { size(1200, 600); frameRate(FPS); imageMode(CENTER); final File dir = dataFile(""); println(dir); String[] imagePaths = {}; int imagesFound = 0; if (dir.isDirectory()) { imagePaths = listPaths(dir.getPath(), "files", "recursi…

---

_[View the full topic](https://discourse.processing.org/t/loading-large-amount-of-image-files/23971)._
