Fix: frame-accurate bg-removal progress text

This commit is contained in:
2026-03-21 01:14:54 -07:00
parent 353a9fff97
commit cb5d666eca

View File

@@ -77,18 +77,19 @@ export async function removeBackgroundFrames(frameDataUrls, { onProgress } = {})
const total = frameDataUrls.length;
for (let i = 0; i < total; i++) {
const frameNo = i + 1;
const src = frameDataUrls[i];
const frameIndex = i;
const frameNo = frameIndex + 1;
const src = frameDataUrls[frameIndex];
onProgress?.({
pct: Math.round((i / total) * 100),
pct: Math.round((frameIndex / total) * 100),
text: `preparing frame ${frameNo} of ${total} for background removal...`
});
const pngFile = await toPngFile(src, `frame-${frameNo}.png`);
onProgress?.({
pct: Math.round((i / total) * 100),
pct: Math.round((frameIndex / total) * 100),
text: `removing background from frame ${frameNo} of ${total}...`
});
@@ -98,7 +99,7 @@ export async function removeBackgroundFrames(frameDataUrls, { onProgress } = {})
progress: (_key, current, stepTotal) => {
if (!stepTotal) return;
const inner = current / stepTotal;
const pct = Math.round(((i + inner) / total) * 100);
const pct = Math.round(((frameIndex + inner) / total) * 100);
onProgress?.({
pct,
text: `removing background from frame ${frameNo} of ${total}...`