# buffer-file-signature

> Determine file type based on signature

Latest version **1.1.1** (published 2022-01-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install buffer-file-signature
pnpm add buffer-file-signature
yarn add buffer-file-signature
bun add buffer-file-signature
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-01-08 |
| First published | 2022-01-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hugo Gomes |
| Maintainers | hugosbg |
| Keywords | file type base64, file signature, detect file type from base64 |

## Links

- npm: https://www.npmjs.com/package/buffer-file-signature
- Repository: https://github.com/hugosbg/buffer-file-signature
- Homepage: https://github.com/hugosbg/buffer-file-signature#readme
- Issues: https://github.com/hugosbg/buffer-file-signature/issues
- npm.io page: https://npm.io/package/buffer-file-signature

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2022-01-08
- 1.0.1 — 2022-01-08
- 1.0.0 — 2022-01-08

## README

# buffer-file-signature

> :hammer: So far it only detects popular image/audio/application types, new types will be added as time goes by and/or we have help.

This package is inspired by [file-type](https://github.com/sindresorhus/file-type) and uses the [file signature](https://en.wikipedia.org/wiki/List_of_file_signatures) as the basis for determining its type.

### why choose me?

- zero dependency
- detects quickly and synchronously

### Install

Node.js

```shell
npm i buffer-file-signature
# or
yarn add buffer-file-signature
```

### Usage

Detects by base64 ( only so far )

```javascript
const file = BufferFileSignature.fromBase64('4AAQSkZJRgA...')

file.extension()
/*
example output: {
    ext: 'jpg',
    mime: 'image/jpeg',
    types: ['jpg', 'jpeg', 'jfif']
}
*/

file.size()
/*
example output: 512000 // bytes
*/
```

Help method for formatting size

```javascript
const file = BufferFileSignature.formatSize(512000)
/*
example output: 500 KB
*/
```

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