From b558db3d78b9bf076a889076ef50c8122e5922f4 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Fri, 17 Nov 2023 15:58:30 +0800 Subject: [PATCH] if noise 0 return empty png --- src/utils/scan-renderer/canvas-scan/create-noise-blob.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/scan-renderer/canvas-scan/create-noise-blob.ts b/src/utils/scan-renderer/canvas-scan/create-noise-blob.ts index 361dc65d..8d12b675 100644 --- a/src/utils/scan-renderer/canvas-scan/create-noise-blob.ts +++ b/src/utils/scan-renderer/canvas-scan/create-noise-blob.ts @@ -13,6 +13,10 @@ export async function createNoiseBlob( throw new Error("Canvas context is null"); } + if (noise === 0) { + return canvas.convertToBlob({ type: "image/png" }); + } + const noiseSVG = getNoiseSVG(noise); const noiseSVGBlob = new Blob([noiseSVG], { type: "image/svg+xml" }); const noiseSVGURL = URL.createObjectURL(noiseSVGBlob);