feat(renderer): render with lower error correction when there is no logo

This commit is contained in:
Pihkaal
2024-10-13 02:13:21 +02:00
parent 82678be6db
commit 9af0e5a567

View File

@@ -9,16 +9,19 @@ export const renderQRCodeToCanvas = async (
logoUrl: string | undefined,
) => {
const canvas = createCanvas(CANVAS_SIZE, CANVAS_SIZE);
const errorCorrectionLevel: QRCode.QRCodeErrorCorrectionLevel = logoUrl
? "H"
: "M";
await QRCode.toCanvas(canvas, content, {
errorCorrectionLevel: "H",
errorCorrectionLevel,
width: CANVAS_SIZE,
margin: 1,
});
if (!logoUrl) return canvas;
const qrCode = QRCode.create(content, { errorCorrectionLevel: "H" });
const qrCode = QRCode.create(content, { errorCorrectionLevel });
const moduleCount = qrCode.modules.size + 2;
const logoImage = await loadImage(logoUrl);