【发布时间】:2022-01-05 23:48:11
【问题描述】:
我有一张我拍摄了一张图片,我正在尝试将这张图片保存到一个文件中。
- 使用 getPixels 获取图像
- ndarray 的片段(我的目标是左上角)
- 将 ndarray 保存为新图像
我的代码:
var getPixels = require("get-pixels");
var fs = require("fs");
var savePixels = require("save-pixels");
let img='path_to_img_file'
getPixels(img, "image/jpeg", function (err, pixels) {
if (err) {
console.log("Bad image", err);
return;
}
pixels = pixels.hi(50, 50, 50); //subset
savePixels(pixels, "png").pipe((p) =>
fs.createWriteStream(p, "shot.png")
);
我的错误:
Unhandled error. ('No data provided')
【问题讨论】:
标签: node.js image image-processing