UNPKG

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)

91 lines (90 loc) 3.35 kB
/** @format */ import { ExifData } from '../exif/exif-data.js'; import { MemoryImage } from '../image/image.js'; import { Decoder, DecoderDecodeOptions } from './decoder.js'; import { ImageFormat } from './image-format.js'; import { TiffInfo } from './tiff/tiff-info.js'; /** * Class representing a TIFF decoder. */ export declare class TiffDecoder implements Decoder { /** * TIFF signature constant. */ private static readonly _tiffSignature; /** * Little-endian byte order constant. */ private static readonly _tiffLittleEndian; /** * Big-endian byte order constant. */ private static readonly _tiffBigEndian; /** * Input buffer for the TIFF data. */ private _input; /** * Information about the TIFF file. */ private _info; /** * Get the TIFF information. */ get info(): TiffInfo | undefined; /** * EXIF data extracted from the TIFF file. */ private _exifData; /** * Get the EXIF data. */ get exifData(): ExifData | undefined; /** * Get the image format. */ get format(): ImageFormat; /** * Get the number of frames available to be decoded. * **startDecode** should have been called first. * Non-animated image files will have a single frame. */ get numFrames(): number; /** * Read the TIFF header and IFD blocks. * @param {InputBuffer<Uint8Array>} p - The input buffer containing the TIFF data. * @returns {TiffInfo | undefined} The TIFF information if valid, otherwise undefined. */ private readHeader; /** * Check if the given file is a valid TIFF image. * @param {Uint8Array} bytes - The file data as a byte array. * @returns {boolean} True if the file is a valid TIFF image, otherwise false. */ isValidFile(bytes: Uint8Array): boolean; /** * Validate the file is a TIFF image and get information about it. * If the file is not a valid TIFF image, undefined is returned. * @param {Uint8Array} bytes - The file data as a byte array. * @returns {TiffInfo | undefined} The TIFF information if valid, otherwise undefined. */ startDecode(bytes: Uint8Array): TiffInfo | undefined; /** * Decode a single frame from the data that was set with **startDecode**. * If **frameIndex** is out of the range of available frames, undefined is returned. * Non-animated image files will only have **frameIndex** 0. * @param {number} frameIndex - The index of the frame to decode. * @returns {MemoryImage | undefined} The decoded image if successful, otherwise undefined. */ decodeFrame(frameIndex: number): MemoryImage | undefined; /** * Decode the file and extract a single image from it. If the file is * animated, the specified **frameIndex** will be decoded. If there was a problem * decoding the file, undefined is returned. * @param {DecoderDecodeOptions} opt - The decode options. * @param {Uint8Array} opt.bytes - The file data as a byte array. * @param {number} [opt.frameIndex] - The index of the frame to decode (optional). * @returns {MemoryImage | undefined} The decoded image if successful, otherwise undefined. */ decode(opt: DecoderDecodeOptions): MemoryImage | undefined; }