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)

326 lines (325 loc) 9.2 kB
/** @format */ import { InputBuffer } from '../../common/input-buffer.js'; import { MemoryImage } from '../../image/image.js'; import { TiffEntry } from './tiff-entry.js'; import { TiffFormat } from './tiff-format.js'; import { TiffImageType } from './tiff-image-type.js'; import { TiffPhotometricType } from './tiff-photometric-type.js'; /** * Represents a TIFF image and provides methods to decode it. */ export declare class TiffImage { /** * Map of TIFF tags to their corresponding entries. */ private readonly _tags; /** * Gets the TIFF tags. */ get tags(): Map<number, TiffEntry>; /** * Width of the image. */ private readonly _width; /** * Gets the width of the image. */ get width(): number; /** * Height of the image. */ private readonly _height; /** * Gets the height of the image. */ get height(): number; /** * Photometric type of the image. */ private _photometricType; /** * Gets the photometric type of the image. */ get photometricType(): TiffPhotometricType; /** * Compression type of the image. */ private _compression; /** * Gets the compression type of the image. */ get compression(): number; /** * Bits per sample in the image. */ private _bitsPerSample; /** * Gets the bits per sample in the image. */ get bitsPerSample(): number; /** * Samples per pixel in the image. */ private _samplesPerPixel; /** * Gets the samples per pixel in the image. */ get samplesPerPixel(): number; /** * Channels per pixel in the image. */ private _channelsPerPixel; /** * Gets the channels per pixel in the image. */ get channelsPerPixel(): number; /** * Sample format of the image. */ private _sampleFormat; /** * Gets the sample format of the image. */ get sampleFormat(): TiffFormat; /** * Type of the image. */ private _imageType; /** * Gets the type of the image. */ get imageType(): TiffImageType; /** * Indicates if white is zero in the image. */ private _isWhiteZero; /** * Gets whether white is zero in the image. */ get isWhiteZero(): boolean; /** * Predictor value for the image. */ private _predictor; /** * Gets the predictor value for the image. */ get predictor(): number; /** * Horizontal chroma subsampling value. */ private _chromaSubH; /** * Gets the horizontal chroma subsampling value. */ get chromaSubH(): number; /** * Vertical chroma subsampling value. */ private _chromaSubV; /** * Gets the vertical chroma subsampling value. */ get chromaSubV(): number; /** * Indicates if the image is tiled. */ private _tiled; /** * Gets whether the image is tiled. */ get tiled(): boolean; /** * Width of the tiles in the image. */ private _tileWidth; /** * Gets the width of the tiles in the image. */ get tileWidth(): number; /** * Height of the tiles in the image. */ private _tileHeight; /** * Gets the height of the tiles in the image. */ get tileHeight(): number; /** * Offsets of the tiles in the image. */ private _tileOffsets; /** * Gets the offsets of the tiles in the image. */ get tileOffsets(): number[] | undefined; /** * Byte counts of the tiles in the image. */ private _tileByteCounts; /** * Gets the byte counts of the tiles in the image. */ get tileByteCounts(): number[] | undefined; /** * Number of tiles in the horizontal direction. */ private _tilesX; /** * Gets the number of tiles in the horizontal direction. */ get tilesX(): number; /** * Number of tiles in the vertical direction. */ private _tilesY; /** * Gets the number of tiles in the vertical direction. */ get tilesY(): number; /** * Size of the tiles in bytes. */ private _tileSize; /** * Gets the size of the tiles in bytes. */ get tileSize(): number | undefined; /** * Fill order of the image. */ private _fillOrder; /** * Gets the fill order of the image. */ get fillOrder(): number; /** * T4 options for the image. */ private _t4Options; /** * Gets the T4 options for the image. */ get t4Options(): number; /** * T6 options for the image. */ private _t6Options; /** * Gets the T6 options for the image. */ get t6Options(): number; /** * Extra samples in the image. */ private _extraSamples; /** * Gets the extra samples in the image. */ get extraSamples(): number | undefined; /** * Number of color map samples in the image. */ private _colorMapSamples; /** * Gets the number of color map samples in the image. */ get colorMapSamples(): number; /** * Color map of the image. */ private _colorMap; /** * Gets the color map of the image. */ get colorMap(): Uint16Array | undefined; /** * Starting index in the color map for the red channel. */ private _colorMapRed; /** * Starting index in the color map for the green channel. */ private _colorMapGreen; /** * Starting index in the color map for the blue channel. */ private _colorMapBlue; /** * Gets whether the image is valid. */ get isValid(): boolean; /** * Constructs a new TiffImage instance. * @param {InputBuffer<Uint8Array>} p - The input buffer containing the TIFF image data. */ constructor(p: InputBuffer<Uint8Array>); /** * Reads the value of a tag of the specified type. * * @param {number} type - The type of the tag to read. * @param {number} [defaultValue=0] - The default value to return if the tag does not exist. * @returns {number} - The value of the tag, or the default value if the tag does not exist. */ private readTag; /** * Reads a list of tags of the specified type. * * @param {number} type - The type of tags to read. * @returns {number[] | undefined} - An array of numbers representing the tags, or undefined if the tag type does not exist. */ private readTagList; /** * Decodes a bilevel tile from the input buffer and writes the decoded data to the image. * * @param {InputBuffer<Uint8Array>} p - The input buffer containing the encoded tile data. * @param {MemoryImage} image - The image object where the decoded tile data will be written. * @param {number} tileX - The x-coordinate of the tile in the image. * @param {number} tileY - The y-coordinate of the tile in the image. * @throws {LibError} Throws an error if the compression type is unsupported. */ private decodeBilevelTile; /** * Decodes a tile from the input buffer and writes the decoded data to the image. * * @param {InputBuffer<Uint8Array>} p - The input buffer containing the tile data. * @param {MemoryImage} image - The image to write the decoded tile data to. * @param {number} tileX - The x-coordinate of the tile. * @param {number} tileY - The y-coordinate of the tile. * @throws {LibError} If an unsupported compression type or bits per sample is encountered. */ private decodeTile; /** * Copies a JPEG tile image into a larger image at a specified position. * * @param {MemoryImage} tile - The source tile image in memory. * @param {MemoryImage} image - The destination image in memory. * @param {number} outX - The x-coordinate in the destination image where the tile should be placed. * @param {number} outY - The y-coordinate in the destination image where the tile should be placed. * @param {number} tileWidth - The width of the tile image. * @param {number} tileHeight - The height of the tile image. */ private jpegToImage; /** * Decodes PackBits encoded data. * * @param {InputBuffer<Uint8Array>} data - The input buffer containing the PackBits encoded data. * @param {number} arraySize - The size of the destination array. * @param {Uint8Array} dst - The destination array where the decoded data will be stored. */ private decodePackBits; /** * Decodes the input buffer into a MemoryImage. * * @param {InputBuffer<Uint8Array>} p - The input buffer containing the image data. * @returns {MemoryImage} - The decoded MemoryImage. */ decode(p: InputBuffer<Uint8Array>): MemoryImage; /** * Checks if the specified tag exists in the tags set. * * @param {number} tag - The tag to check for existence. * @returns {boolean} - Returns true if the tag exists, otherwise false. */ hasTag(tag: number): boolean; }