main
mula.liu 2026-02-10 01:48:41 +08:00
parent f66a78aa38
commit ba8e2d7220
2 changed files with 25 additions and 7 deletions

View File

@ -223,6 +223,7 @@ async function processSingle(item) {
originalInfo.innerHTML = ` originalInfo.innerHTML = `
<div>Type: PDF (NotebookLM)</div> <div>Type: PDF (NotebookLM)</div>
<div>${i18n.t('info.size')}: ${(item.file.size / 1024 / 1024).toFixed(2)} MB</div> <div>${i18n.t('info.size')}: ${(item.file.size / 1024 / 1024).toFixed(2)} MB</div>
<div>&nbsp;</div>
`; `;
setStatusMessage('NotebookLM PDF Detected', 'success'); setStatusMessage('NotebookLM PDF Detected', 'success');
} else { } else {
@ -281,12 +282,13 @@ async function processSingle(item) {
processedInfo.innerHTML = ` processedInfo.innerHTML = `
<div>${i18n.t('info.status')}: ${i18n.t('info.removed')}</div> <div>${i18n.t('info.status')}: ${i18n.t('info.removed')}</div>
<div>Output: PDF</div> <div>Output: PDF</div>
<div>&nbsp;</div>
`; `;
} else { } else {
processedInfo.innerHTML = ` processedInfo.innerHTML = `
<div>${i18n.t('info.size')}: ${img.width}×${img.height}</div> <div>${i18n.t('info.size')}: ${img.width}×${img.height}</div>
<div>${i18n.t('info.status')}: ${i18n.t('info.removed')}</div> <div>${i18n.t('info.status')}: ${i18n.t('info.removed')}</div>
<div>Output: IMAGE</div> <div>&nbsp;</div>
`; `;
} }
@ -460,7 +462,7 @@ async function processPdf(file, onProgress) {
for (let i = 1; i <= total; i++) { for (let i = 1; i <= total; i++) {
if (onProgress) onProgress(i, total); if (onProgress) onProgress(i, total);
const page = await pdf.getPage(i); const page = await pdf.getPage(i);
const viewport = page.getViewport({ scale: 3 }); const viewport = page.getViewport({ scale: 2 });
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
canvas.width = viewport.width; canvas.width = viewport.width;
@ -489,7 +491,7 @@ async function processPdf(file, onProgress) {
const cleanedCanvas = await engine.removeWatermarkFromImage(canvas, { forceSimpleClone: true }); 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 // Capture first page as preview
if (i === 1) { if (i === 1) {

View File

@ -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) { function isNotebookLM(width, height) {
return (width === 571 && height === 1024) || // Exact checks
(width === 1536 && height === 2752) || if ((width === 571 && height === 1024) ||
(width === 2752 && height === 1536); (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;
} }
/** /**