r/p5js • • 24d ago

Loading Errors

My project has about 50 images so far and every time i try run my code, it comes up with failed to load image over and over. How do i fix this please help

2 Upvotes

9 comments sorted by

2

u/JoeWhy2 24d ago

Are you doing this in the P5JS editor and have you looked at the updates to p5.js v2?

1

u/ElectroBeast_ 24d ago

Im on version 1.11.13 cause thats when i started the project. Do you think thats causing it?

1

u/JoeWhy2 24d ago

It seems to be better in v2 but there are major changes to how you load media. I did a sketch recently in v2 with almost 500 images. It takes a while to load but always works. https://p5js.org/tutorials/v2_transition/

1

u/ElectroBeast_ 24d ago

I updated it and did the version 2 async stuff but after a minuet it always comes up with this error message:

TypeError: Content-Length header of network response exceeds response Body.

You may have encountered a CORS error

🌸 p5.js says: It looks like there was a problem loading your image...

1

u/JoeWhy2 24d ago

Are you trying to run your sketch as a local file? It has to go through a server. If you're using VS Code, install the Live Server extension and open the HTML file with it.

1

u/ElectroBeast_ 24d ago

idk what that means, im just trying to do my coursework

1

u/forgotmyusernamedamm 24d ago

Does it work with one image? If so, does it work with 20? How many images break it?
Is it failing to load on the same image each time? Make 100% sure there are no spelling mistakes and you have the extension correct.
Try loading just that image on its own.
What version of p5.js are you using? If you're using 2.0 or greater are you using the async setup?
How big are your images? If you are compressing them anyways, try reducing the size before importing.
If none of this works, trying to isolate the problem into the shortest code possible. Eliminate everything but the bug, then give us some code to look at.

1

u/ElectroBeast_ 24d ago

I don't think its to do with that because some times it runs perfectly fine, but most of the time it just either takes minuets to load or fails to at all