-
Notifications
You must be signed in to change notification settings - Fork 851
Open
Labels
Description
Describe the bug
const fs = require('fs');
const path = require('path');
const cv = require("opencv");
const sourcePath = "./test.tiff";
const targetPath = "./test.jpg";
console.log("before image resize");
let content = fs.readFileSync(sourcePath);
console.log(`content type: ${content instanceof Buffer}`);
cv.readImage(content, function(err, mat) {
mat.resize(640, 360);
// mat.save(targetPath);
let buf = mat.toBuffer({ext: ".jpg", jpegQuality: 100});
var targetFile = fs.openSync(targetPath, "w");
fs.writeFileSync(targetFile, buf, {encoding: 'binary', flag: 'w'});
fs.closeSync(targetFile);
console.log("convert image");
});
console.log("after image resize");
breeze@breeze-desktop:~/Work/uber-test/xviz/examples/data-server$ nodejs ./opencv-tiff2jpeg.js
before image resize
content type: true
OpenCV Error: Unspecified error (failed to write image data to temporary file) in imdecode_, file /home/breeze/Work/data/vehicle_data/impl-ros-kinetic/script/tmp/opencv-3.3.0/modules/imgcodecs/src/loadsave.cpp, line 657
/home/breeze/Work/uber-test/xviz/examples/data-server/opencv-tiff2jpeg.js:15
mat.resize(640, 360);
^
TypeError: Cannot read property 'resize' of null
at /home/breeze/Work/uber-test/xviz/examples/data-server/opencv-tiff2jpeg.js:15:6
at Object.<anonymous> (/home/breeze/Work/uber-test/xviz/examples/data-server/opencv-tiff2jpeg.js:14:4)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
OS / Libraries
- Ubuntu 16.04