Image doesn't show

Can someone tell me where is wrong?

I am a new programmer, I try to run my code, then I got this:

The file “psa.jpg” is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
NullPointerException

This is the code:

PImage photo;

void setup() {
size(100, 100);
photo = loadImage(“psa.jpg”);
}

void draw() {
image(photo, 0, 0);
}

I double-checked the name of my picture, it is as same as “psa.jpg”

Hello,

It works fine here.

Reference:
https://processing.org/reference/loadImage_.html

Is it in the correct folder?

:)

Please format your code:
https://discourse.processing.org/faq#format-your-code

PImage photo;

void setup() {
  size(100, 100);
  photo = loadImage("psa.jpg");
}

void draw() {
  image(photo, 0, 0);
}

you can hit ctrl-k in processing to open the folder of your sketch.

here (or in the data folder inside it) the file psa.jpg must be!!!

Make sure it’s the right spelling, it’s case-sensitive, so JPG is not allowed…

…and .png is now allowed…

@lukeltw,

Is it in the correct folder?

The reference for loadImage() that I provided states:
“To load correctly, images must be located in the …”
You can look it up.

If you drag and drop an image onto the sketch window it will put in the directory referenced in loadImage().

:)

yes, now its working, thank you!

1 Like

Its working now! Thank you for your help! @glv :slight_smile:

1 Like