Ask Your Question

Revision history [back]

Berak , thx for your note, I found a great site that explains datauri conversion options with opencv.js https://github.com/justadudewhohacks/opencv4nodejs/blob/master/README.md

// load base64 encoded image const base64text='data:image/png;base64,R0lGO..';//Base64 encoded string const base64data =base64text.replace('data:image/jpeg;base64','') .replace('data:image/png;base64','');//Strip image type prefix const buffer = Buffer.from(base64data,'base64'); const image = cv.imdecode(buffer); //Image is now represented as Mat

// convert Mat to base64 encoded jpg image const outBase64 = cv.imencode('.jpg', croppedImage).toString('base64'); // Perform base64 encoding const htmlImg=''; //Create insert into HTML compatible tag