lukeltw
October 18, 2020, 11:03pm
1
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”
glv
October 18, 2020, 11:08pm
2
PImage photo;
void setup() {
size(100, 100);
photo = loadImage("psa.jpg");
}
void draw() {
image(photo, 0, 0);
}
Chrisir
October 19, 2020, 10:56am
5
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…
glv
October 19, 2020, 11:41am
6
@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
1 Like