# buffer-type

> Detect content-type from Buffer data.

Latest version **1.0.0** (published 2018-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install buffer-type
pnpm add buffer-type
yarn add buffer-type
bun add buffer-type
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-06-28 |
| First published | 2013-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8.0.0 |
| Dependencies | 0 |
| Unpacked size | 19.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | fengmk2 |
| Maintainers | fengmk2 |
| Keywords | buffer-type, image-type, content-type, buffer, type, mime, filetype, file extension, buffer type |

## Links

- npm: https://www.npmjs.com/package/buffer-type
- Repository: https://github.com/node-modules/buffer-type
- Issues: https://github.com/node-modules/buffer-type/issues
- npm.io page: https://npm.io/package/buffer-type

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-06-28
- 0.0.2 — 2014-05-04
- 0.0.1 — 2013-08-14

## README

buffer-type
=======

[![NPM version][npm-image]][npm-url]
[![NPM quality][quality-image]][quality-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![NPM download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/buffer-type.svg?style=flat-square
[npm-url]: https://npmjs.org/package/buffer-type
[quality-image]: http://npm.packagequality.com/shield/buffer-type.svg?style=flat-square
[quality-url]: http://packagequality.com/#?package=buffer-type
[travis-image]: https://img.shields.io/travis/node-modules/buffer-type.svg?style=flat-square
[travis-url]: https://travis-ci.org/node-modules/buffer-type
[codecov-image]: https://img.shields.io/codecov/c/github/node-modules/buffer-type.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/node-modules/buffer-type
[david-image]: https://img.shields.io/david/node-modules/buffer-type.svg?style=flat-square
[david-url]: https://david-dm.org/node-modules/buffer-type
[snyk-image]: https://snyk.io/test/npm/buffer-type/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/buffer-type
[download-image]: https://img.shields.io/npm/dm/buffer-type.svg?style=flat-square
[download-url]: https://npmjs.org/package/buffer-type

Detect content-type from Buffer data.

## Install

```bash
$ npm install buffer-type
```

## Usage

```js
const bt = require('buffer-type');
const fs = require('fs');

const info = bt(fs.readFileSync(__dirname + '/logo.png'));
console.log(info);
// {
//   type: 'image/png',
//    extension: '.png',
//    width: 618,
//    height: 96,
//    bit: 8, // bit depth
//    color: 6,
//    compression: 0,
//    filter: 0,
//    interlace: 0
// }
```

## References

* http://www.onicos.com/staff/iz/formats/
* http://www.fastgraph.com/help/image_file_header_formats.html
* http://en.wikipedia.org/wiki/Portable_Network_Graphics
* http://en.wikipedia.org/wiki/Image_file_format

## TODO

* Image
  * [√] .png
  * [√] .jpg
  * [√] .bmp
  * [√] .gif
  * [√] .webp
  * [ ] .svg
  * [ ] .tif
  * [ ] .psd
* Tar
  * [ ] .tar
  * [ ] .gzip
  * [ ] .zip
  * [ ] .rar
* PE file
  * [ ] .exe
  * [ ] .msi
  * [ ] .apk
  * [ ] .ipa
* Text
  * [ ] .xml
  * [ ] .html
  * [ ] .json
* Media
  * [ ] .mp3
  * [ ] .mp4
  * [ ] .avi

## License

[MIT](LICENSE.txt)

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