Search processing.org:

Reference for Processing version 1.0.1+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Class | PImage

Name

### save()

Examples

    PImage img = loadImage("tower.jpg");
    img.save("img.jpg");

    size(100, 100);
    PImage img = loadImage("tower.jpg");
    PImage newImg = createImage(100, 100, RGB);
    newImg = img.get();
    newImg.save("newImg.jpg");

Description

Saves the image into a file. Images are saved in TIFF, TARGA, JPEG, and PNG format depending on the extension within the filename parameter. For example, "image.tif" will have a TIFF image and "image.png" will save a PNG image. If no extension is included in the filename, the image will save in TIFF format and .tif will be added to the name. These files are saved to the sketch's folder, which may be opened by selecting "Show sketch folder" from the "Sketch" menu. It is not possible to use save() while running the program in a web browser.
To save an image created within the code, rather than through loading, it's necessary to make the image with the createImage() function so it is aware of the location of the program and can therefore save the file to the right place. See the createImage() reference for more information.

Syntax

    img.save(filename)

Parameters

img | PImage: any variable of type PImage
filename | String: a sequence of letters and numbers

Returns | none
Usage | Web & Application

Updated on November 22, 2008 08:39:25pm PST