Files
goodbuddy/tests/support/pptx-fixture.ts
T
mesalogo 8a63ac9ee8 fix: recognize PPTX images and release idle OCR memory
Image-only PPTX attachments failed with no indexable text even when a local
OCR model was configured. PPTX parsing now recognizes embedded PNG, JPEG
and WebP images through the existing local OCR path, preserves native text
and slide locators, and honors the selected parsing workflow.

OCR workers previously retained model sessions and WASM memory indefinitely
after successful parsing. Release the worker after 60 seconds with no active
or queued requests, reuse it for continuous work, and reload on demand.
Fast text/index modes still skip OCR. This does not render Office layouts,
recognize inherited master images, or change Agent execution permissions.

Validated four real PPTX attachments (40 pages), idle memory release and a
nine-page reimport after model reload on Windows x64 with PP-OCRv6 Tiny.
49 local OCR requests and zero text-model calls. All 4293 tests passed
with 67 skipped; typecheck, lint and the isolated Electron build passed.

Release note: 修复已配置本地 OCR 时图片型 PPTX 仍无法导入的问题,识别结果保留幻灯片定位。OCR 空闲 60 秒后自动释放模型运行内存,连续解析复用模型,下次使用时自动重新加载。
2026-09-15 16:58:28 +08:00

17 lines
636 B
TypeScript

import { strToU8, zipSync } from 'fflate'
export function createImagePptx(nativeText = '', pageCount = 1): Buffer {
const files: Record<string, Uint8Array> = {
'ppt/media/image1.png': new Uint8Array([1, 2, 3])
}
for (let page = 1; page <= pageCount; page += 1) {
files[`ppt/slides/slide${page}.xml`] = strToU8(
`<p:sld><a:p><a:t>${nativeText}</a:t></a:p><p:pic><a:blip r:embed="rId1"/></p:pic></p:sld>`
)
files[`ppt/slides/_rels/slide${page}.xml.rels`] = strToU8(
'<Relationships><Relationship Id="rId1" Target="../media/image1.png"/></Relationships>'
)
}
return Buffer.from(zipSync(files))
}