0

I'm trying to use processing in IntelliJ and I'm having trouble importing/running an image file. The console is saying that the file cannot be reached because it is not in my sketch. What is a sketch and how do I add a file to it?

I've made sure the file name is right so I don't think that is the issue.

import processing.core.PApplet;
import processing.core.PImage;

public class image2 extends PApplet {
    public static void main(String[] args) {
        PApplet.main("image2");
    }

    public void settings() {
        size(1920, 1080);
    }
    PImage photo;

    public void setup() {
        size(1920, 1080);
        photo =  loadImage("testimage.jpg");
    }
    public void draw(){}
}
Dushyant Tankariya
  • 1,432
  • 3
  • 11
  • 17
sam24
  • 11
  • 2

1 Answers1

2

Place your image in the data folder and use dataPath()

photo =  loadImage(dataPath("testimage.jpg"));

(alternatively use sketchPath() photo = loadImage(sketchPath("testimage.jpg"));)

(Your issue is similar to this one)

George Profenza
  • 50,687
  • 19
  • 144
  • 218