Open fk242 opened 5 years ago
@fk242 thats how I do it:
const encodeParams = [cv.IMWRITE_PNG_COMPRESSION, quality]
const buffer = await cv.imencodeAsync('.png', mat, encodeParams)
fs.writeFileSync(filepath, buffer)
That works, thank you!
Strangely, compression through imwrite
doesn't work after the resize()
method has been called on the image file. @stoefln solution works well in this case.
Just noticed the same problem. Seems to be a bug.
I was trying to set PNG compression level when writing image to a file with imwriteAsync, but haven't found a way to do it.
In Python, that would be:
cv2.imwrite(filename, img, [cv2.IMWRITE_PNG_COMPRESSION, 9])
Is it possible to set this option in opencv4nodejs? Thank you.