I utilized the Ngx-Webcam
tool to capture images from my camera. My goal is to obtain both high quality and low quality images from the camera.
Although this library provides me with Base64 images, it offers an option to reduce the size using imageQuality
. However, I cannot use this feature as I require both high quality and low quality images.
let data = webcamImage.imageAsBase64;
const raw = window.atob(data);
const rawLength = raw.length;
const unit8array = new Uint8Array(new ArrayBuffer(rawLength));
for (let i = 0; i < rawLength; i++) {
unit8array[i] = raw.charCodeAt(i);
}
I attempted to implement a solution using https://www.npmjs.com/package/image-conversion for our issue.
let data = webcamImage.imageAsBase64;
const raw = window.atob(data);
let contentType = raw.split(';')[0];
const rawLength = raw.length;
const unit8array = new Uint8Array(new ArrayBuffer(rawLength));
for (let i = 0; i < rawLength; i++) {
unit8array[i] = raw.charCodeAt(i);
}
let blob = new Blob([unit8array], {type: contentType});
imageProcess.compress(blob, 0.4);
Unfortunately, this approach did not work. I am now seeking another solution to compress the image.