@types/utif
TypeScript icon, indicating that this package has built-in type declarations

3.0.5 • Public • Published

Installation

npm install --save @types/utif

Summary

This package contains type definitions for utif (https://github.com/photopea/UTIF.js).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/utif.

index.d.ts

import "node";

export as namespace UTIF;

export type TiffTag = string[] | number[];

/**
 * Each IFD is an object, keys are "tXYZ" (XYZ is a TIFF tag number), values are values of these tags.
 * You can get the the dimension (and other properties, "metadata") of the image without decompressing pixel data.
 * For more information on what each tag means, refer https://github.com/photopea/UTIF.js/blob/master/UTIF.js#L742 or TIFF 6 specification.
 */
// eslint-disable-next-line @typescript-eslint/naming-convention
export interface IFD {
    [property: string]: TiffTag | number | Uint8Array;
    data: Uint8Array;
    width: number;
    height: number;
}

/**
 * Returns an array of "IFDs" (image file directories).
 *
 * @param buffer A Buffer or ArrayBuffer containing TIFF or EXIF data.
 */
export function decode(buffer: Buffer | ArrayBuffer): IFD[];

/**
 * If there is an image inside the IFD, it is decoded and three new properties are added to the IFD: width, height and data.
 * Note: TIFF files may have various number of channels and various color depth. The interpretation of data depends on many tags (see the TIFF 6 specification).
 *
 * @param buffer A Buffer or ArrayBuffer containing TIFF or EXIF data
 * @param ifd The element of the output of UTIF.decode()
 */
export function decodeImage(buffer: Buffer | ArrayBuffer, ifd: IFD): void;

/**
 * Returns Uint8Array of the image in RGBA format, 8 bits per channel (ready to use in context2d.putImageData() etc.)
 *
 * @param ifd An image file directory
 */
export function toRGBA8(ifd: IFD): Uint8Array;

/**
 * Returns an ArrayBuffer of the binary TIFF file.
 * Note: No compression available right now.
 *
 * @param rgba A Uint8Array containing RGBA pixel data.
 * @param w Width of the image.
 * @param h Height of the image.
 * @param metadata [optional] The image file directory which should be encoded.
 */
export function encodeImage(rgba: Uint8Array, w: number, h: number, metadata?: IFD): ArrayBuffer;

/**
 * Returns ArrayBuffer of binary data which can be used to encode EXIF data.
 *
 * @param ifds The array of IFDs (image file directories) to be encoded.
 */
export function encode(ifds: IFD[]): ArrayBuffer;

/**
 * Replaces all Image elements in the document with Canvas elements.
 * The attributes "id", "class" and "style" will be copied from the original Image to the new Canvas.
 */
export function replaceIMG(): void;

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: @types/node

Credits

These definitions were written by Jan Pesa, Naveen Kumar Sangi, and Massimiliano Caniparoli.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/utif

Weekly Downloads

7,958

Version

3.0.5

License

MIT

Unpacked Size

7.8 kB

Total Files

5

Last publish

Collaborators

  • types