fix bugs
parent
f66a78aa38
commit
ba8e2d7220
|
|
@ -223,6 +223,7 @@ async function processSingle(item) {
|
|||
originalInfo.innerHTML = `
|
||||
<div>Type: PDF (NotebookLM)</div>
|
||||
<div>${i18n.t('info.size')}: ${(item.file.size / 1024 / 1024).toFixed(2)} MB</div>
|
||||
<div> </div>
|
||||
`;
|
||||
setStatusMessage('NotebookLM PDF Detected', 'success');
|
||||
} else {
|
||||
|
|
@ -281,12 +282,13 @@ async function processSingle(item) {
|
|||
processedInfo.innerHTML = `
|
||||
<div>${i18n.t('info.status')}: ${i18n.t('info.removed')}</div>
|
||||
<div>Output: PDF</div>
|
||||
<div> </div>
|
||||
`;
|
||||
} else {
|
||||
processedInfo.innerHTML = `
|
||||
<div>${i18n.t('info.size')}: ${img.width}×${img.height}</div>
|
||||
<div>${i18n.t('info.status')}: ${i18n.t('info.removed')}</div>
|
||||
<div>Output: IMAGE</div>
|
||||
<div> </div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue