Search code examples
imagedirectoryprocessingloadimage

How to load the most fresh image from a directory in processing


Please, let me know how to get processing to load the newest image from a directory.

img = loadImage("pic1.jpg"); is the basic example


Solution

  • I tried the code from user2468700 and didn't worked so I jumped into the reference and ended up with something like this:

        void callImage () {
         File dir = new File(dataPath(""));
         String [] list = dir.list();
         img = loadImage (path+list[list.length-1]);
         image(img, 0, 0);
        }
    

    It will load from the "data" directory in your sketch directory. Hope this helps someone :)