Saving images from drawing

Can you point me to an example of saving image(s)? I want to save an image or sequence of images of what is drawn using p5py.
I assume this relates to using the offscreen buffer. Please clarify.

this what you’re looking for?
saveFrame() / Reference /

1 Like

Yes, that works for me, thanks!

1 Like

Since you are using p5py you can save image sequences with save_frame(). From the documentation:


p5. save_frame (filename=‘screen.png’ )

Save a numbered sequence of images whenever the function is run.

Saves a numbered sequence of images, one image each time the function is run. To save an image that is identical to the display window, run the function at the end of p5.draw() or within mouse and key events such as p5.mouse_pressed() and p5.key_pressed().

If save_frame() is used without parameters, it will save files as screen-0000.png, screen-0001.png, and so on. Append a file extension, to indicate the file format to be used. Image files are saved to the sketch’s folder. Alternatively, the files can be saved to any location on the computer by using an absolute path (something that starts with / on Unix and Linux, or a drive letter on Windows).

Parameters: filename (str) – name (or name with path) of the image file. (defaults to screen.png)

Source: Output — p5 0.8.1 documentation