Function write

  • Write an image to the disk. The file format is determined automatically from the file's extension. If the extension is not supported, an error will be thrown.

    Parameters

    • path: string | URL

      Path or file URL where the image should be written.

    • image: Image | Mask

      Image to save.

    • Optional options: WriteOptions

      Write options.

    Returns Promise<void>

    A promise that resolves when the image is written.

  • Write an image to the disk as PNG. When the png format is specified, the file's extension doesn't matter.

    Parameters

    • path: string | URL

      Path or file URL where the image should be written.

    • image: Image | Mask

      Image to save.

    • options: WriteOptionsPng

      Encode options for png images.

    Returns Promise<void>

    A promise that resolves when the image is written.

  • Write an image to the disk as JPEG. When the jpeg format is specified, the file's extension doesn't matter.

    Parameters

    • path: string | URL

      Path or file URL where the image should be written.

    • image: Image | Mask

      Image to save.

    • options: WriteOptionsJpeg

      Encode options for jpeg images.

    Returns Promise<void>

    A promise that resolves when the image is written.

  • Write an image to the disk as BMP. When the bmp format is specified, the file's extension doesn't matter.

    Parameters

    • path: string | URL

      Path or file URL where the image should be written.

    • image: Mask

      Image to save.

    • Optional options: WriteOptionsBmp

      Encode options for bmp images.

    Returns Promise<void>

    A promise that resolves when the image is written.