is-tif

2.0.0 • Public • Published

is-tif

Check if a Buffer/Uint8Array is a TIFF image

Install

$ npm install is-tif

Usage

Node.js
import {readChunkSync} from 'read-chunk';
import isTif from 'is-tif';

const buffer = readChunkSync('unicorn.tif', {length: 4});

isTif(buffer);
//=> true
Browser
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.tif');
xhr.responseType = 'arraybuffer';

xhr.onload = () => {
	isTif(new Uint8Array(this.response));
	//=> true
};

xhr.send();

API

isTif(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 4 bytes.

Related

  • file-type - Detect the file type of a Buffer/Uint8Array

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    71
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    71
  • 1.0.1
    7
  • 1.0.0
    2
  • 0.1.1
    438
  • 0.1.0
    0

Package Sidebar

Install

npm i is-tif

Weekly Downloads

346

Version

2.0.0

License

MIT

Unpacked Size

2.92 kB

Total Files

4

Last publish

Collaborators

  • sindresorhus