// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com

// Example 15-1: "Hello World" images

// Declaring a variable of type PImage, a class available to us from the Processing core library.
PImage img; 

void setup() {
  // Make a new instance of a PImage by loading an image file
  img = loadImage("mysummervacation.jpg");

void draw() {
   //The image() function displays the image at a location-in this case the point (0,0).
  • Groland

    It seems important to say explicitly in the text that the image filename extension, “.jpg”, “.png” is required. I wasted some time and got a lot of errors by neglecting to include these extensions.

  • Anonymous

    Great comment, I will include a note for the next edition!

  • Ken

    hi, I follow the instruction, but there is an error. It says “Cannot find anything named img” Could you pls tell how to fix it?

  • feligallo2002

    it’s there cause you are not declaring the PImage variable, so before the void setup you must declare the variable:

    PImage img;
    void setup

  • http://www.facebook.com/anuta.vlad Anuta Vlad

    What is PImage? I’m ussing NetBeans and he did not recognize it.”a class available to us from the Processing core library.”.Which library?

  • Anonymous

    A Processing class for images.  You probably need an import statement.

    import processing.core.*;


  • blandit

    at  img = loadImage(“mysummervacation.jpg”); where is location the mysummervacation.jpg??if i put the image in folder on my hardisk, can i change mysummervacation.jpg with the URL of my image??

  • Anonymous

    Download the example, you’ll see the image goes in the sketch’s “data” folder.  You can also use a full path instead.

  • sarthij10