image-type识别图片真实类型
作者:
AsaGuo | 来源:发表于
2019-05-30 14:54 被阅读0次
- Install
npm install --save image-type
npm install read-chunk
- Usage
let readChunk = require('read-chunk');
let imageType = require('image-type');
let image_path = 'avatar.png'
let buffer = readChunk.sync(image_path, 0, image_path.length);
let image_type = imageType(buffer);
if (image_type)
//=> {ext: 'png', mime: 'image/png'}
console.log('avatar.png is an image');
else
console.log('avatar.png is not an image');
本文标题:image-type识别图片真实类型
本文链接:https://www.haomeiwen.com/subject/cbqvtctx.html
网友评论