From ba8e2d722042976ac8e7a02a22d509b89f4c30ae Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Tue, 10 Feb 2026 01:48:41 +0800 Subject: [PATCH] fix bugs --- src/app.js | 8 +++++--- src/core/watermarkEngine.js | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/app.js b/src/app.js index f0d13d6..3a2150b 100644 --- a/src/app.js +++ b/src/app.js @@ -223,6 +223,7 @@ async function processSingle(item) { originalInfo.innerHTML = `
Type: PDF (NotebookLM)
${i18n.t('info.size')}: ${(item.file.size / 1024 / 1024).toFixed(2)} MB
+
 
`; setStatusMessage('NotebookLM PDF Detected', 'success'); } else { @@ -281,12 +282,13 @@ async function processSingle(item) { processedInfo.innerHTML = `
${i18n.t('info.status')}: ${i18n.t('info.removed')}
Output: PDF
+
 
`; } else { processedInfo.innerHTML = `
${i18n.t('info.size')}: ${img.width}×${img.height}
${i18n.t('info.status')}: ${i18n.t('info.removed')}
-
Output: IMAGE
+
 
`; } @@ -460,7 +462,7 @@ async function processPdf(file, onProgress) { for (let i = 1; i <= total; i++) { if (onProgress) onProgress(i, total); const page = await pdf.getPage(i); - const viewport = page.getViewport({ scale: 3 }); + const viewport = page.getViewport({ scale: 2 }); const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); canvas.width = viewport.width; @@ -489,7 +491,7 @@ async function processPdf(file, onProgress) { const cleanedCanvas = await engine.removeWatermarkFromImage(canvas, { forceSimpleClone: true }); - const imgData = cleanedCanvas.toDataURL('image/jpeg', 0.95); + const imgData = cleanedCanvas.toDataURL('image/jpeg', 0.8); // Capture first page as preview if (i === 1) { diff --git a/src/core/watermarkEngine.js b/src/core/watermarkEngine.js index 2aa4537..51008af 100644 --- a/src/core/watermarkEngine.js +++ b/src/core/watermarkEngine.js @@ -27,12 +27,28 @@ const NOTEBOOK_CLONE_CONFIG = { }; /** - * Check if image is from NotebookLM based on exact dimensions + * Check if image is from NotebookLM based on aspect ratio or dimensions */ function isNotebookLM(width, height) { - return (width === 571 && height === 1024) || - (width === 1536 && height === 2752) || - (width === 2752 && height === 1536); + // Exact checks + if ((width === 571 && height === 1024) || + (width === 1536 && height === 2752) || + (width === 2752 && height === 1536)) { + return true; + } + + // Ratio checks for scaled content (e.g. PDF rendering) + const ratio = width / height; + const tolerance = 0.01; + + // Standard NotebookLM ratios + // ~0.558 (571/1024, 1536/2752) + // ~1.792 (2752/1536) + if (Math.abs(ratio - 0.558) < tolerance || Math.abs(ratio - 1.792) < tolerance) { + return true; + } + + return false; } /**