Improve image quality if the images are being saved
This commit is contained in:
parent
8b0b07a367
commit
b20156031b
1 changed files with 6 additions and 2 deletions
|
|
@ -102,13 +102,17 @@ async function onRecord() {
|
||||||
const ctx = canvas.getContext("2d");
|
const ctx = canvas.getContext("2d");
|
||||||
assert(ctx !== null);
|
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.width = video_.videoWidth * scale; // Yes, slightly redundant
|
||||||
canvas.height = video_.videoHeight * scale;
|
canvas.height = video_.videoHeight * scale;
|
||||||
ctx.drawImage(video_, 0, 0, canvas.width, canvas.height);
|
ctx.drawImage(video_, 0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
const blob = await new Promise<Blob | null>((resolve) => {
|
const blob = await new Promise<Blob | null>((resolve) => {
|
||||||
|
if (originals.value) {
|
||||||
|
canvas.toBlob(resolve, "image/jpeg", 0.9);
|
||||||
|
} else {
|
||||||
canvas.toBlob(resolve);
|
canvas.toBlob(resolve);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
assert(blob !== null);
|
assert(blob !== null);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue