Expression painter:write(f) saves the image associated with the painter into the file named f. Argument f can be a file name or a Lua file descriptor.

The image data is obtained using function painter:image(). The image format is determined by the optional string argument format or deduced from the file name extension.