Directory of Images Associated With Project

I need to load,one at the time, lots of images that are sitting at my desktop. A single picture can be displayed by using :
function setup() {
createCanvas(576, 720);
img = createImg(‘image3.jpg’);
img.hide();
}
I am using the p5js web editor I am not sure if this editor has the tools to accomplish that. I tried to load all my images using the load images feature but I was able to load only 24 of them.
If my pictures are located at C:\Users\Owner\Desktop\Images, How do I associate the directory of images located on my desktop folder within my p5js project?
I tried a loop to read the images sequentially and I gave a path to my variable with no luck. Then, I tried the line below but It did not work.
img = createImg(“C:\Users\Owner\Desktop\Images”+ image+index.jpg

Can you please point me in the right direction?

Thanks

Did you consider setting up your own local host and run things locally from your computer? It might save you some trouble if the Web Editor isn’t entirely suited for your situation:

And could you clarify what you mean by ‘load, one at the time’? Should all the images load one by one before your sketch runs, or should it load a new image once you interact with the sketch?

EDIT
Keep forgetting that the Processing environment can run p5 sketches. The solution below by @jeremydouglass might be be easier than my suggestion

That won’t work. It can’t access your desktop / local filesystem.

For LOTS of images that live on your computer I would suggest using PDE (install from processing.org), click on “Java” and change to “p5.js” mode, and create a sketch with p5.js mode on your Desktop or in your Processing sketchbook folder. Then you can save the sketch on your computer, add the folder of images to the sketch, and load as many as you like.

If you want the images to live online and they aren’t private then you could upload them to a public webserver and load them from your editor.p5js.org sketch by their URLs.

2 Likes

Should all the images load one by one before your sketch runs, or should it load a new image once you interact with the sketch?

The second approach fits my needs.
I will check your edited note as well.

Thanks

I will give a try to your suggestion. Everything is located on my PC and pictures won’t be live.

Thanks very much.

I set up a local server with google app and everything worked as suggested and I appreciated the inputs given.

Thanks very much

Forum

1 Like