Improve image quality if the images are being saved

This commit is contained in:
Joscha 2025-04-09 15:04:33 +02:00
parent 8b0b07a367
commit b20156031b

View file

@ -102,13 +102,17 @@ async function onRecord() {
const ctx = canvas.getContext("2d");
assert(ctx !== null);
const scale = 384 / video_.videoWidth;
const scale = originals.value ? 1 : 384 / video_.videoWidth;
canvas.width = video_.videoWidth * scale; // Yes, slightly redundant
canvas.height = video_.videoHeight * scale;
ctx.drawImage(video_, 0, 0, canvas.width, canvas.height);
const blob = await new Promise<Blob | null>((resolve) => {
canvas.toBlob(resolve);
if (originals.value) {
canvas.toBlob(resolve, "image/jpeg", 0.9);
} else {
canvas.toBlob(resolve);
}
});
assert(blob !== null);