image-js
Version:
Image processing and manipulation in JavaScript
62 lines • 2.96 kB
TypeScript
import type { Image } from '../Image.js';
import { Mask } from '../Mask.js';
import type { EncodeOptionsBmp, EncodeOptionsJpeg, EncodeOptionsPng } from './encode.js';
export interface WriteOptions {
/**
* If true, attempts to create all the missing directories recursively.
*/
recursive?: boolean;
}
export type WriteOptionsPng = WriteOptions & EncodeOptionsPng;
export type WriteOptionsJpeg = WriteOptions & EncodeOptionsJpeg;
export type WriteOptionsBmp = WriteOptions & EncodeOptionsBmp;
/**
* 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.
* This method is only implemented for Node.js.
* @param path - Path or file URL where the image should be written.
* @param image - Image to save.
* @param options - Write options.
* @returns A promise that resolves when the image is written.
*/
export declare function write(path: string | URL, image: Image | Mask, options?: WriteOptions): Promise<void>;
/**
* Write an image to the disk as PNG.
* When the `png` format is specified, the file's extension doesn't matter.
* This method is only implemented for Node.js.
* @param path - Path or file URL where the image should be written.
* @param image - Image to save.
* @param options - Encode options for png images.
* @returns A promise that resolves when the image is written.
*/
export declare function write(path: string | URL, image: Image | Mask, options: WriteOptionsPng): Promise<void>;
/**
* Write an image to the disk as JPEG.
* When the `jpeg` format is specified, the file's extension doesn't matter.
* This method is only implemented for Node.js.
* @param path - Path or file URL where the image should be written.
* @param image - Image to save.
* @param options - Encode options for jpeg images.
* @returns A promise that resolves when the image is written.
*/
export declare function write(path: string | URL, image: Image | Mask, options: WriteOptionsJpeg): Promise<void>;
/**
* Write an image to the disk as BMP.
* When the `bmp` format is specified, the file's extension doesn't matter.
* This method is only implemented for Node.js.
* @param path - Path or file URL where the image should be written.
* @param image - Image to save.
* @param options - Encode options for bmp images.
* @returns A promise that resolves when the image is written.
*/
export declare function write(path: string | URL, image: Mask, options?: WriteOptionsBmp): Promise<void>;
/**
* Synchronous version of {@link write}.
* This method is only implemented for Node.js.
* @param path - Path where the image should be written.
* @param image - Image to save.
* @param options - Encode options.
*/
export declare function writeSync(path: string | URL, image: Image | Mask, options?: WriteOptionsBmp | WriteOptionsPng | WriteOptionsJpeg | WriteOptions): void;
//# sourceMappingURL=write.d.ts.map