Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tiff

image-js249.7kMIT7.0.0TypeScript support: included

TIFF image decoder written entirely in JavaScript

readme

Zakodium logo

Maintained by Zakodium

tiff

NPM version npm download test coverage license

TIFF image decoder written entirely in JavaScript.

Installation

npm install tiff

Compatibility

TIFF standard

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

Complete API documentation

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

changelog

Changelog

7.0.0 (2025-06-15)

⚠ BREAKING CHANGES

  • migrate to ESM (#68)

Code Refactoring

6.2.0 (2025-03-06)

Features

6.1.1 (2024-09-12)

Bug Fixes

  • support Deflate compression code (#56) (d965602)

6.1.0 (2024-05-21)

Features

6.0.0 (2024-04-08)

⚠ BREAKING CHANGES

  • removed firstImage option, use pages option instead.

Features

Bug Fixes

5.0.3 (2021-11-05)

Bug Fixes

  • support some malformed images without StripByteCounts (56058a9)

5.0.2 (2021-10-31)

Bug Fixes

  • correctly decode images from pooled buffers (fcbbc34)
  • make LZW more robust (72a6180)

5.0.1 (2021-10-12)

Bug Fixes

5.0.0 (2021-07-06)

⚠ BREAKING CHANGES

  • Removed support for Node.js 10.

Miscellaneous Chores

  • stop testing on Node.js 10 (220822f)

4.3.0 (2020-12-03)

Features

  • add support for Zlib/deflate compression (7d3a04c)

4.2.0 (2020-08-21)

Features

  • add support for alpha channel and compressed 16-bit images (5f2e612)

4.1.3 (2020-08-07)

Bug Fixes

  • support images that do not define samplesPerPixel (2c2587b)

4.1.2 (2020-08-06)

Bug Fixes

  • really correct decoding of RGB images (5595c53)

4.1.1 (2020-08-06)

Bug Fixes

  • correctly support RGB images (d546610)

4.1.0 (2020-08-04)

Features

  • support LZW compression (20fbb50)

4.0.0 (2020-01-23)

chore

  • stop supporting Node.js 6 and 8 (1156f52)

Features

  • add support for palette images (d31413b)

BREAKING CHANGES

  • Node.js 6 and 8 are no longer supported.

3.0.1 (2018-09-12)

Bug Fixes

3.0.0 (2017-10-25)

Chores

  • remove Node 4 from travis (5c743d2)

Features

  • add pageCount and isMultiPage functions (7dac89f)

BREAKING CHANGES

  • Stop support for Node 4

2.1.0 (2016-11-05)

Features

  • add support for uncompressed RGB data (b3ffff7)

2.0.1 (2016-09-20)

Bug Fixes

  • return decimal numbers for rational types (c3bad6c)

2.0.0 (2016-09-20)

Code Refactoring

  • hide the decoder class behind a decode function (78603ff)

Features

  • add support for decoding EXIF and GPS IFDs (b2766a5)
  • allow to pass iobuffer options to the decoder (97f0f8e)

BREAKING CHANGES

  • The API has changed. Use tiff.decode() instead of TIFFDecoder.

1.1.1 (2016-04-25)

Bug Fixes

  • default value for compression field is 1 (14c13a4)

1.1.0 (2015-12-04)

1.0.0 (2015-11-23)

0.0.2 (2015-09-20)

0.0.1 (2015-09-19)