Reference save()

save()

Saves the image to a file.

By default, img.save() saves the image as a PNG image called untitled.png.

The first parameter, filename, is optional. It's a string that sets the file's name. If a file extension is included, as in img.save('drawing.png'), then the image will be saved using that format.

The second parameter, extension, is also optional. It sets the files format. Either 'png' or 'jpg' can be used. For example, img.save('drawing', 'jpg') saves the canvas to a file called drawing.jpg.

Note: The browser will either save the file immediately or prompt the user with a dialogue window.

The image will only be downloaded as an animated GIF if it was loaded from a GIF file. See saveGif() to create new GIFs.

Examples

Syntax

save(filename, [extension])

Parameters

filename

filename. Defaults to 'untitled'.

extension

file extension, either 'png' or 'jpg'. Defaults to 'png'.

Notice any errors or typos? Please let us know. Please feel free to edit src/image/p5.Image.js and open a pull request!

Related References