Files
SnapOtter/tests/unit/api/animation-detect.test.ts
T
SnapOtterandGitHub cb5db59f77 feat(tools): remove background from animated GIFs (WebP, APNG) (#502)
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.
2026-07-11 19:53:00 +08:00

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);
});
});