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
+5 -3
View File
@@ -580,11 +580,13 @@ describe("detectFaceLandmarks", () => {
expect(result.landmarks).toBeNull();
});
it("does not use sharp to convert to PNG (writes buffer directly)", async () => {
it("converts input buffer to PNG before writing", async () => {
await detectFaceLandmarks(FAKE_INPUT);
// face-landmarks writes inputBuffer directly, no sharp conversion
expect(writeFile).toHaveBeenCalledWith(expect.stringContaining("face_landmarks_"), FAKE_INPUT);
expect(writeFile).toHaveBeenCalledWith(
expect.stringContaining("face_landmarks_"),
Buffer.from("mock-png-data"),
);
});
it("cleans up temp file in finally block", async () => {