buffer-type

Detect content-type from Buffer data.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
buffer-type
1321.0.05 years ago10 years agoMinified + gzip package size for buffer-type in KB

Readme

buffer-type
!NPM versionnpm-imagenpm-url !NPM qualityquality-imagequality-url !build statustravis-imagetravis-url !Test coveragecodecov-imagecodecov-url !David depsdavid-imagedavid-url !Known Vulnerabilitiessnyk-imagesnyk-url !NPM downloaddownload-imagedownload-url
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

  • http://www.onicos.com/staff/iz/formats/
  • http://www.fastgraph.com/help/imagefileheaderformats.html
  • http://en.wikipedia.org/wiki/PortableNetworkGraphics
  • http://en.wikipedia.org/wiki/Imagefileformat

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