diff --git a/src/services/background.js b/src/services/background.js index ea47e8d..ceedc0f 100644 --- a/src/services/background.js +++ b/src/services/background.js @@ -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}...`