mirror of
https://github.com/vibegif/vibegif.lol.git
synced 2026-04-07 18:22:13 +00:00
Fix: frame-accurate bg-removal progress text
This commit is contained in:
@@ -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}...`
|
||||
|
||||
Reference in New Issue
Block a user