【文件属性】:
文件名称:is-jpg:检查BufferUint8Array是否为JPEG图像
文件大小:229KB
文件格式:ZIP
更新时间:2021-05-26 08:01:49
JavaScript
is-jpg
检查Buffer / Uint8Array是否为图像
安装
$ npm install is-jpg
用法
Node.js
const readChunk = require ( 'read-chunk' ) ;
const isJpg = require ( 'is-jpg' ) ;
const buffer = readChunk . sync ( 'unicorn.jpg' , 0 , 3 ) ;
isJpg ( buffer ) ;
//=> true
浏览器
const xhr = new XMLHttpRequest ( ) ;
xhr . open ( 'GET' , 'unicorn.jpg' ) ;
xhr . responseType = 'arraybuffer' ;
xhr . onload = ( ) => {
isJpg ( new U
【文件预览】:
is-jpg-main
----fixture.png(53KB)
----.gitignore(23B)
----fixture.jpg(58KB)
----.github()
--------workflows()
----.gitattributes(29B)
----package.json(722B)
----readme.md(826B)
----fixture-issue1.jpg(93KB)
----index.js(176B)
----test.js(516B)
----fixture-tiny.jpg(107B)
----fixture-imageoptim.jpg(33KB)
----.editorconfig(175B)
----license(1KB)
----.npmrc(19B)