justadudewhohacks / justadudewhohacks/opencv4nodejs
Issue with .imdecode(..), .getData(..) and Buffers
- Dominant language
- C++
- Stars
- 5.1k
- Forks
- 826
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
i would like to get image data loaded by **.imdecode(..)** method and write that data into image file,
so i used this code:
```
let c = cv.imdecode(data); // "data" is a **Buffer** variable
const imageBuffer = c.getData();
const buff = Buffer.from(imageBuffer);
let path = `uploads/${new Date().getTime()}.jpg`;
fs.writeFileSync(path, buff );
```
The code above created the image file, but it is corrupted (it displayed "failed to load image data" in explorer)..
after some researches, i tried this one too:
```
let c = cv.imdecode(data); // data is a **Buffer** variable
const imageBuffer = c.getData();
let ut8 = new Uint8Array(imageBuffer);
for (let i=0; i
Contributor guide
Assessment
This issue has not been assessed yet.