npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

is-tif

2.0.0

@sindresorhus

npmHomeRepoSnykSocket
Downloads:682
$ npm install is-tif
DailyWeeklyMonthlyYearly

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