mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Adds a dedicated remove-gif-background AI tool: removes the background from an animated GIF, WebP, or APNG frame by frame and reassembles a transparent (or composited) animation in WebP, APNG, or GIF, with full per-frame effects. Reuses the background-removal bundle. Verified end-to-end with the real rembg model. Closes #496.
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { detectAnimation } from "../../../apps/api/src/lib/animation-detect.js";
|
|
import { fixtures, readFixture } from "../../fixtures/index.js";
|
|
|
|
describe("detectAnimation", () => {
|
|
it("counts GIF frames via Sharp", async () => {
|
|
const r = await detectAnimation(readFixture(fixtures.image.animated.gif), "animated.gif");
|
|
expect(r.animated).toBe(true);
|
|
expect(r.frames).toBeGreaterThan(1);
|
|
});
|
|
|
|
it("counts animated WebP frames via Sharp", async () => {
|
|
const r = await detectAnimation(readFixture(fixtures.image.animated.webp), "animated.webp");
|
|
expect(r.animated).toBe(true);
|
|
expect(r.frames).toBeGreaterThan(1);
|
|
});
|
|
|
|
it("counts APNG frames via the acTL chunk", async () => {
|
|
const r = await detectAnimation(readFixture(fixtures.image.animated.apng), "animated.apng");
|
|
expect(r.animated).toBe(true);
|
|
expect(r.frames).toBe(4);
|
|
});
|
|
|
|
it("treats a still PNG as not animated", async () => {
|
|
const r = await detectAnimation(readFixture(fixtures.image.base.png200), "still.png");
|
|
expect(r.animated).toBe(false);
|
|
expect(r.frames).toBe(1);
|
|
});
|
|
});
|