is-xcf
Version:
Check if a buffer/Uint8Array is an XCF image
59 lines (36 loc) • 1.07 kB
Markdown
is-xcf [](https://travis-ci.org/pskupinski/is-xcf)
======
Check if a Buffer/Uint8Array is an [XCF] image
Inspired by [sindresorhus](https://github.com/sindresorhus) and his wonderful repos like [is-gif](https://github.com/sindresorhus/is-gif).
```sh
npm install --save is-xcf
```
```sh
bower install --save is-xcf
```
```js
var fs = require('fs');
var isXCF = require('is-xcf');
var buffer = fs.readFileSync('awesome.xcf');
isXCF(buffer); // returns true
```
```js
var xhr = new XMLHttpRequest();
xhr.open('GET', 'awesome.xcf');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
isXCF(new Uint8Array(this.response)); // returns true
};
xhr.send();
```
Accepts a Buffer or Unit8Array.
Only needs the first 8 bytes, more is fine though.
This module is [ISC licensed](https://github.com/pskupinski/is-xcf/blob/master/LICENSE).
[]: http://en.wikipedia.org/wiki/XCF_(file_format)