tiff
TIFF image decoder written entirely in JavaScript.
Installation
npm i tiff
Compatibility
Platform
This package is written using ES2015 features. It is natively compatible with
recent web browsers and Node.js. You can transpile it with a tool like
babel if you need to support more JavaScript engines.
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.
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 pixelswidth
- number of columnsheight
- number of rowsbitsPerSample
- bit depthalpha
- true
if the image has an additional alpha channelxResolution
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