# whether-image

> check a file whether image

Latest version **0.0.3** (published 2021-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install whether-image
pnpm add whether-image
yarn add whether-image
bun add whether-image
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-02-08 |
| First published | 2021-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Hancel.Lin |
| Maintainers | imlinhanchao |
| Keywords | image, file, photo, picture, pic, jpg, jpeg, png, gif, webp, tiff, tif, bmp, is-image, is-jpg, is-png, is-gif, is-webp, is-bmp |

## Links

- npm: https://www.npmjs.com/package/whether-image
- Repository: https://github.com/imlinhanchao/whether-image
- Homepage: https://github.com/imlinhanchao/whether-image#readme
- Issues: https://github.com/imlinhanchao/whether-image/issues
- npm.io page: https://npm.io/package/whether-image

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-02-08
- 0.0.2 — 2021-02-08
- 0.0.1 — 2021-02-08

## README

# Whether Image

A module used to determine whether a file is a picture. Judge based on the file header.

## Installation
```bash
npm install whether-image
```

## Usage

```typescript
// Get Image Real type
import img from 'whether-image';
img.getImageSuffix('your/image/file/path'); 
// => `bmp` or `jpg` or `jpeg` or `png` or `gif` or `webp` or `tiff` or `tif`
```

```typescript
// Check is Image
import img from 'whether-image';
img.isImage('your/image/file/path');
// => true or false
```

## Parameters

```typescript
function getImageSuffix(file: ArrayBufferView | string, suffixs: Array<string>): string 
function isImage(file: ArrayBufferView | string, suffixs: Array<string>): boolean 
```

|parameter|description|
|--|--|
|file|The file path or byte that you want to check.|
|suffixs|The suffixs list you want to check. (Optional)|

### Support Image Type
- You can get it from variable `suffixs`. There are `bmp`, `jpg`, `jpeg`, `png`, `gif`, `webp`, `tiff`, `tif`.

---
_Source: https://npm.io/package/whether-image · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
