image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
72 lines (71 loc) • 2.74 kB
TypeScript
/** @format */
/**
* Represents metadata for a file.
*
* @property {boolean} cpr - Indicates if the file is compressed.
* @property {number} usize - The uncompressed size of the file.
* @property {number} crc - The cyclic redundancy check value for the file.
* @property {Uint8Array} file - The file data as a byte array.
*/
interface FileMetadata {
cpr: boolean;
usize: number;
crc: number;
file: Uint8Array;
}
/**
* Options for the deflate compression algorithm.
* @property {number} level - Compression level.
*/
interface DeflateOptions {
/**
* Compression level.
* A higher level means more compression but slower performance.
*/
level: number;
}
/**
* Parses a ZIP file buffer.
* @param {ArrayBuffer} buf - The ZIP file buffer.
* @param {boolean} onlyNames - Whether to only extract file names.
* @returns {Record<string, FileMetadata>} The parsed file information.
*/
export declare function parse(buf: ArrayBuffer, onlyNames: boolean): Record<string, FileMetadata>;
/**
* Encodes a set of files into a ZIP file buffer.
* @param {Record<string, Uint8Array>} obj - The files to encode.
* @param {boolean} [noCmpr] - Whether to disable compression.
* @returns {ArrayBuffer} The encoded ZIP file buffer.
*/
export declare function encode(obj: Record<string, Uint8Array>, noCmpr?: boolean): ArrayBuffer;
/**
* Compresses data using the deflate algorithm without headers.
* @param {Uint8Array} data - The data to compress.
* @param {DeflateOptions} [opts] - The options object.
* @param {number} [opts.level=6] - The compression level.
* @returns {Uint8Array} The compressed data.
*/
export declare function deflateRaw(data: Uint8Array, opts?: DeflateOptions): Uint8Array;
/**
* Compresses data using the deflate algorithm with headers.
* @param {Uint8Array} data - The data to compress.
* @param {DeflateOptions} [opts] - The options object.
* @param {number} [opts.level=6] - The compression level.
* @returns {Uint8Array} The compressed data.
*/
export declare function deflate(data: Uint8Array, opts?: DeflateOptions): Uint8Array;
/**
* Decompresses data using the inflate algorithm.
* @param {Uint8Array} file - The compressed data.
* @param {Uint8Array} buf - The buffer to store decompressed data.
* @returns {Uint8Array} The decompressed data.
*/
export declare function inflate(file: Uint8Array, buf?: Uint8Array): Uint8Array;
/**
* Decompresses data using the raw inflate algorithm.
* @param {Uint8Array} file - The compressed data.
* @param {Uint8Array} buf - The buffer to store decompressed data.
* @returns {Uint8Array} The decompressed data.
*/
export declare function inflateRaw(file: Uint8Array, buf?: Uint8Array): Uint8Array;
export {};