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.
示例
语法
save(filename, [extension])
参数
filename. Defaults to 'untitled'.
file extension, either 'png' or 'jpg'. Defaults to 'png'.