https://github.com/nielse63/if-is-image
Check if a string, filepath, or url references an image file
https://github.com/nielse63/if-is-image
file-types image javascript node
Last synced: 3 months ago
JSON representation
Check if a string, filepath, or url references an image file
- Host: GitHub
- URL: https://github.com/nielse63/if-is-image
- Owner: nielse63
- License: mit
- Created: 2017-07-06T14:22:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-01-27T16:36:00.000Z (over 3 years ago)
- Last Synced: 2024-04-25T17:05:16.476Z (about 1 year ago)
- Topics: file-types, image, javascript, node
- Language: JavaScript
- Size: 497 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# if-is-image
[](https://travis-ci.org/nielse63/if-is-image)
[](https://coveralls.io/github/nielse63/if-is-image?branch=master)
[](https://david-dm.org/nielse63/if-is-image?type=dev)
[](https://codeclimate.com/github/nielse63/if-is-image)
[](http://badge.fury.io/js/if-is-image)
[](https://www.npmjs.com/package/if-is-image)
[](https://greenkeeper.io/)Check if a string, filepath, or url references an image file.
## Installation
### With `npm`
```bash
npm install if-is-image
```### With `yarn`
```bash
yarn add if-is-image
```## Usage
### In a node project
Import the script to your project
```js
import ifIsImage from 'if-is-image';
// or
const ifIsImage = require('if-is-image');
```And execute the script:
```js
const isImage = ifIsImage('path/to/file'); // false
const isImage = ifIsImage('path/to/image.jpg'); // true
const isImage = ifIsImage('path/to/image.webp'); // true
const isImage = ifIsImage({}); // throw: Path to image must be a string
```## Contributing
Fork the repo and clone locally, then run:
```bash
yarn install
```This will install the `devDependencies` packages and build the `lib` folder.
Once you've made your desired changes, make sure to write any new tests for
your feature and run the tests:```bash
yarn run lint # lints js
yarn test # runs test suite
```If all tests pass, [create a pull request](https://github.com/nielse63/if-is-image/pulls).