Skip to content
io
png
write_png

write_png

Mojo function 🡭

write_png

fn def write_png(canvas: Canvas, path: String, level: PngLevel = PngLevel.DEFAULT)

Write canvas to path as an 8-bit, non-interlaced PNG – color type 6 (truecolor + alpha) if any pixel is not fully opaque, color type 2 (truecolor) otherwise. The bytes are encode_png’s.

Args:

  • canvas (Canvas): Canvas to write.
  • path (String): File path to write to.
  • level (PngLevel): How hard to work at making the file small. Every level decodes to the same pixels; see PngLevel for what each costs and saves.

Raises:

Error: path can’t be opened for writing.