- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

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

Name | ### requestImage()
Examples |
    PImage bigImage;

    void setup() {
      bigImage = requestImage("something.jpg");
    }

    void draw() {
      if (bigImage.width == 0) {
        // Image is not yet loaded
      } else if (bigImage.width == -1) {
        // This means an error occurred during image loading
      } else {
        // Image is ready to go, draw it
        image(bigImage, 0, 0);
      }
    }
Description | This function loads images on a separate thread so that your sketch doesn't freeze while images load during setup(). While the image is loading, its width and height will be 0. If an error occurs while loading the image, its width and height will be set to -1. You'll know when the image has loaded properly because its width and height will be greater than 0. Asynchronous image loading (particularly when downloading from a server) can dramatically improve performance. The extension parameter is used to determine the image type in cases where the image filename does not end with a proper extension. Specify the extension as the second parameter to requestImage().
Syntax |
    requestImage(filename)
    requestImage(filename, extension)
Parameters |
filename | String: name of the file to load, can be .gif, .jpg, .tga, or a handful of other image types depending on your platform
extension | String: the type of image to load, for example "png", "gif", "jpg"
Returns | PImage
Related | PImage loadImage()

Updated on July 4, 2018 11:56:42am EDT