https://github.com/shinnn/is-cwebp-readable
Check if a Buffer/Uint8Array is available for cwebp image source
https://github.com/shinnn/is-cwebp-readable
buffer cwebp file-format file-type javascript magic-numbers nodejs uint8array webp
Last synced: about 1 month ago
JSON representation
Check if a Buffer/Uint8Array is available for cwebp image source
- Host: GitHub
- URL: https://github.com/shinnn/is-cwebp-readable
- Owner: shinnn
- License: isc
- Created: 2015-01-27T17:49:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-12-17T13:49:00.000Z (over 6 years ago)
- Last Synced: 2025-04-09T22:54:15.140Z (about 1 month ago)
- Topics: buffer, cwebp, file-format, file-type, javascript, magic-numbers, nodejs, uint8array, webp
- Language: JavaScript
- Homepage: https://npm.runkit.com/is-cwebp-readable
- Size: 87.9 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-cwebp-readable
[](https://www.npmjs.com/package/is-cwebp-readable)
[](https://travis-ci.com/shinnn/is-cwebp-readable)
[](https://coveralls.io/github/shinnn/is-cwebp-readable)Check if a Buffer/Uint8Array is available for [cwebp](https://developers.google.com/speed/webp/docs/cwebp) image source
```javascript
const {readFileSync} = require('fs');
const isCwebpReadable = require('is-cwebp-readable');isCwebpReadable(readFileSync('fixture.png')); //=> true
isCwebpReadable(readFileSync('fixture.bmp')); //=> false
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install is-cwebp-readable
```## API
```javascript
const isCwebpReadable = require('is-cwebp-readable');
```### isCwebpReadable(*data*)
*data*: [`Buffer`](https://nodejs.org/api/buffer.html#buffer_class_buffer) or [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
Return: `boolean`It returns `true` if the data is [PNG](https://wikipedia.org/wiki/Portable_Network_Graphics), [JPEG](https://wikipedia.org/wiki/JPEG), [TIFF](https://wikipedia.org/wiki/Tagged_Image_File_Format), or [WebP](https://wikipedia.org/wiki/WebP), otherwise `false`.
## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe