save

fun Image.save(path: String)(source)

Writes this image to the file at path as a PNG file with four 8-bit channels, creating the file or replacing its contents. Image.decode reads it back pixel for pixel.

A relative path resolves against Files.basePath; an absolute one is used as given. A missing directory on the way to the file is created first, as Files.writeBytes does.

Has no sample because it writes a file to disk.

Throws

if the file cannot be created or written, for example because a part of its path is a file rather than a directory.

if the encoder runs out of memory.