Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 26 days 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 (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-12-17T13:49:00.000Z (almost 6 years ago)
- Last Synced: 2024-09-21T23:29:59.393Z (about 2 months 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
[![npm version](https://img.shields.io/npm/v/is-cwebp-readable.svg)](https://www.npmjs.com/package/is-cwebp-readable)
[![Build Status](https://travis-ci.com/shinnn/is-cwebp-readable.svg?branch=master)](https://travis-ci.com/shinnn/is-cwebp-readable)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/is-cwebp-readable.svg)](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