This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name | ### image()
Examples |
    PImage img;

    void setup() {
      // Images must be in the "data" directory to load correctly
      img = loadImage("laDefense.jpg");
    }

    void draw() {
      image(img, 0, 0);
    }
    PImage img;

    void setup() {
      // Images must be in the "data" directory to load correctly
      img = loadImage("laDefense.jpg");
    }

    void draw() {
      image(img, 0, 0);
      image(img, 0, 0, width/2, height/2);
    }
Description | The image() function draws an image to the display window. Images must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the image to the data directory, or just drag the image file onto the sketch window. Processing currently works with GIF, JPEG, and PNG images. The img parameter specifies the image to display and by default the a and b parameters define the location of its upper-left corner. The image is displayed at its original size unless the c and d parameters specify a different size. The imageMode() function can be used to change the way these parameters draw the image. The color of an image may be modified with the tint() function. This function will maintain transparency for GIF and PNG images.
Syntax |
    image(img, a, b)
    image(img, a, b, c, d)
Parameters |
img | PImage: the image to display
a | float: x-coordinate of the image
b | float: y-coordinate of the image
c | float: width to display the image
d | float: height to display the image
Returns | void
Related | loadImage() PImage imageMode() tint() background() alpha()

Updated on May 19, 2014 05:30:01pm PDT