图像数据
检索一个 图像数据 从一个图像, 在两个 浏览器 财务报告和审定财务报表 节点.js同步或同步。 还出口a ImageData 组合填充 节点.js,允许您在两种环境中输入检查实例.
一个 ImageData 对象总是包含以下属性:
dataUint8ClampedArray代表一个一维阵列,包含RGBA顺序中的数据,整数值为0至255(包含).
width未签名长代表图像数据的实际宽度,以像素为单位.
height未签名长代表图像数据的实际高度, 像素.
支持的格式
- jpeg 语句
- 树
- 数字f
- bmp 数据
- 微调
安装
使用 npm
npm install @andreekeberg/imagedata
使用线条
yarn add @andreekeberg/imagedata
开始
作为 ES6 模块导入
import { get, getSync } from '@andreekeberg/imagedata'
导入为普通JS 模块
const { get, getSync } = require('@andreekeberg/imagedata')
用法 (浏览器)
同步
可用输入类型
| 类型 | 说明 |
|---|---|
string | 图像文件路径 |
HTMLImageElement | 提及a <img> 元素 |
File | 通常从一个返回 <input> 元素 |
Blob | 原始二进制数据blob |
示例
get('image.jpg', (error, data) => {
if (error) {
console.log(error)
} else {
console.log(data)
}
})
同步
可用输入类型
| 类型 | 说明 |
|---|---|
HTMLImageElement | 提及a <img> 元素 |
丢出一个
Error如果提供的图像未完成装入
示例
const image = document.querySelector('img')
try {
console.log(getSync(image))
} catch(error) {
console.log(error)
}
用法(节点.js)
同步
可用输入类型
| 类型 | 说明 |
|---|---|
string | 图像文件路径 |
Buffer | 创建于 fs.readFile 或者说 fs.readFileSync |
fs.ReadStream | 创建于 fs.createReadStream |
示例
get('image.jpg', (error, data) => {
if (error) {
console.log(error)
} else {
console.log(data)
}
})
同步
可用输入类型
| 类型 | 说明 |
|---|---|
string | 图像文件路径 |
Buffer | 创建于 fs.readFile 或者说 fs.readFileSync |
示例
try {
console.log(getSync('image.jpg'))
} catch(error) {
console.log(error)
}
文档
捐款
读取 捐款准则。 。 。 .
更改日志
参见 更改日志 为整个项目的历史.
许可证
图像数据在 麻省理工学院许可证。 。 。 .