Reference save()

save()

Saves a given element(image, text, json, csv, wav, or html) to the client's computer. The first parameter can be a pointer to element we want to save. The element can be one of p5.Element,an Array of Strings, an Array of JSON, a JSON object, a p5.Table , a p5.Image, or a p5.SoundFile (requires p5.sound). The second parameter is a filename (including extension).The third parameter is for options specific to this type of object. This method will save a file that fits the given parameters. If it is called without specifying an element, by default it will save the whole canvas as an image file. You can optionally specify a filename as the first parameter in such a case. Note that it is not recommended to call this method within draw, as it will open a new save dialog on every render.

Examples

Syntax

save([objectOrFilename], [filename], [options])

Parameters

objectOrFilename

If filename is provided, will save canvas as an image with either png or jpg extension depending on the filename. If object is provided, will save depending on the object and filename (see examples above).

filename

If an object is provided as the first parameter, then the second parameter indicates the filename, and should include an appropriate file extension (see examples above).

options

Additional options depend on filetype. For example, when saving JSON, true indicates that the output will be optimized for filesize, rather than readability.

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

Related References