Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 28 days 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-27T16:36:00.000Z (almost 3 years ago)
- Last Synced: 2024-04-25T17:05:16.476Z (7 months 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
[![Build Status](https://travis-ci.org/nielse63/if-is-image.svg?branch=master)](https://travis-ci.org/nielse63/if-is-image)
[![Coverage Status](https://coveralls.io/repos/github/nielse63/if-is-image/badge.svg?branch=master)](https://coveralls.io/github/nielse63/if-is-image?branch=master)
[![devDependencies Status](https://david-dm.org/nielse63/if-is-image/dev-status.svg)](https://david-dm.org/nielse63/if-is-image?type=dev)
[![Code Climate](https://codeclimate.com/github/nielse63/if-is-image/badges/gpa.svg)](https://codeclimate.com/github/nielse63/if-is-image)
[![NPM version](https://badge.fury.io/js/if-is-image.svg)](http://badge.fury.io/js/if-is-image)
[![npm](https://img.shields.io/npm/dt/if-is-image.svg?style=flat-square)](https://www.npmjs.com/package/if-is-image)
[![Greenkeeper badge](https://badges.greenkeeper.io/nielse63/if-is-image.svg)](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).