fix: convert input buffer to PNG before passing to face landmarks Python sidecar

AVIF (and other Sharp-native formats) were written as raw bytes to a
.png temp file, causing PIL to fail with "cannot identify image file".
Every other AI module wrapper already converts via sharp().png().toBuffer()
before writing; face-landmarks was the only one that skipped this step.
This commit is contained in:
SnapOtter
2026-05-13 14:18:49 +08:00
parent 0b3f46407a
commit 648c8c12f5
4 changed files with 15 additions and 10 deletions
+4 -3
View File
@@ -68,13 +68,14 @@ describe("detectFaceLandmarks", () => {
);
});
it("writes input buffer directly without sharp conversion", async () => {
it("converts input buffer to PNG before writing", async () => {
const sharp = (await import("sharp")).default;
await detectFaceLandmarks(FAKE_INPUT);
// face-landmarks.ts does NOT use sharp -- it writes inputBuffer directly
expect(sharp).toHaveBeenCalledWith(FAKE_INPUT);
expect(writeFile).toHaveBeenCalledWith(
expect.stringContaining("face_landmarks_"),
FAKE_INPUT,
Buffer.from("mock-png-data"),
);
});