Skip to content

image-js/tiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5df3dc1 · Mar 7, 2025
Dec 22, 2023
Mar 6, 2025
Mar 6, 2025
Nov 14, 2019
Mar 5, 2025
Nov 6, 2019
Mar 6, 2025
Sep 19, 2015
Mar 7, 2025
Jul 17, 2017
Mar 6, 2025
Nov 14, 2019
Nov 14, 2019
Oct 12, 2021

Repository files navigation

Zakodium logo

Maintained by Zakodium

tiff

NPM version npm download test coverage license

TIFF image decoder written entirely in TypeScript.

Installation

npm i tiff

Compatibility

The library can currently decode greyscale and RGB images (8, 16 or 32 bits). It supports LZW compression and images with an additional alpha channel.

Extensions

Images compressed with Zlib/deflate algorithm are also supported.

API

tiff.decode(data[, options])

Decodes the file and returns TIFF IFDs.

IFD object

Each decoded image is stored in an IFD.

IFD#data

The data property is a Typed Array containing the pixel data. It is a Uint8Array for 8bit images, a Uint16Array for 16bit images and a Float32Array for 32bit images.

Other properties of IFD
  • size - number of pixels
  • width - number of columns
  • height - number of rows
  • bitsPerSample - bit depth
  • alpha - true if the image has an additional alpha channel
  • xResolution
  • yResolution
  • resolutionUnit

tiff.pageCount(data)

Returns the number of IFDs (pages) in the file.

tiff.isMultiPage(data)

Returns true if the file has 2 or more IFDs (pages) and false if it has 1. This is slightly more efficient than calling pageCount() if all you need to know is whether the file has multiple pages or not.

License

MIT