Image not recognized

Hello I was to create a sketch in p5js in the atom editor. As part of it I tried to upload an image and I got this error:

Refused to execute script from 'http://127.0.0.1:3000/Draw-Pixel/MyGame.png' because its MIME type ('image/png') is not executable.

i tried this with JPEG, JPG, PNG and XCEF, and I always got the same error (of course the file extension and name changed). I don’t have p5 DOM installed I don’t know if that means anything, It didn’t come when I downloaded p5js complete.
Please help soon.
image

error libraries

1 Like

Hello,

This line in index.html makes the browser download that image and try parsing it as JavaScript. That will fail miserably, and that’s why the error shows up.

<script src="MyGame.png"></script>
4 Likes

Thank you @Sven.
So what is the correct do it?

Remove that line of HTML. It makes no sense, including an image as a script. What is it that you’re trying to accomplish with that?

1 Like

Oh my god it worked!
Thank you so much. :+1:

1 Like

You’re most welcome, @virtuous1. :blush: If you don’t mind me asking, can you remember why that line of HTML was put there in the first place?

Yeah I was watching this tutorial on how to add an image to p5js and I think they said (or I misunderstood that they said) to put in that line in HTML, I don’t even remember where I saw it.
Maybe it was a coding train video?
:man_shrugging:
Either way thanks.

1 Like