From b20156031b8a86881154ca38b980299bcb1d14b5 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 9 Apr 2025 15:04:33 +0200 Subject: [PATCH] Improve image quality if the images are being saved --- showbits-thermal-printer-ui/src/AppPhoto.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/showbits-thermal-printer-ui/src/AppPhoto.vue b/showbits-thermal-printer-ui/src/AppPhoto.vue index fc2866f..3daf7c4 100644 --- a/showbits-thermal-printer-ui/src/AppPhoto.vue +++ b/showbits-thermal-printer-ui/src/AppPhoto.vue @@ -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((resolve) => { - canvas.toBlob(resolve); + if (originals.value) { + canvas.toBlob(resolve, "image/jpeg", 0.9); + } else { + canvas.toBlob(resolve); + } }); assert(blob !== null);