Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

buffer-type

node-modules4.6kMIT1.0.0

Detect content-type from Buffer data.

buffer-type, image-type, content-type, buffer, type, mime, filetype, file extension, buffer type

readme

buffer-type

NPM version NPM quality build status Test coverage David deps Known Vulnerabilities NPM download

Detect content-type from Buffer data.

Install

$ npm install buffer-type

Usage

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

TODO

  • Image
    • [√] .png
    • [√] .jpg
    • [√] .bmp
    • [√] .gif
    • [√] .webp
    • <input disabled="" type="checkbox"> .svg
    • <input disabled="" type="checkbox"> .tif
    • <input disabled="" type="checkbox"> .psd
  • Tar
    • <input disabled="" type="checkbox"> .tar
    • <input disabled="" type="checkbox"> .gzip
    • <input disabled="" type="checkbox"> .zip
    • <input disabled="" type="checkbox"> .rar
  • PE file
    • <input disabled="" type="checkbox"> .exe
    • <input disabled="" type="checkbox"> .msi
    • <input disabled="" type="checkbox"> .apk
    • <input disabled="" type="checkbox"> .ipa
  • Text
    • <input disabled="" type="checkbox"> .xml
    • <input disabled="" type="checkbox"> .html
    • <input disabled="" type="checkbox"> .json
  • Media
    • <input disabled="" type="checkbox"> .mp3
    • <input disabled="" type="checkbox"> .mp4
    • <input disabled="" type="checkbox"> .avi

License

MIT

changelog

1.0.0 / 2018-06-28

others

0.0.2 / 2014-05-04

  • add webp detect

0.0.1 / 2013-08-13

  • add bmp detect
  • add jpeg detect
  • add png image detect
  • add gif image detect
  • first commit