mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -1,6 +1,7 @@
|
||||
import { unlink, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import sharp from "sharp";
|
||||
import { type ProgressCallback, parseStdoutJson, runPythonWithProgress } from "./bridge.js";
|
||||
|
||||
export interface FaceLandmarkPoint {
|
||||
@@ -33,7 +34,8 @@ export async function detectFaceLandmarks(
|
||||
const inputPath = join(tmpdir(), `face_landmarks_${Date.now()}.png`);
|
||||
|
||||
try {
|
||||
await writeFile(inputPath, inputBuffer);
|
||||
const pngBuffer = await sharp(inputBuffer).png().toBuffer();
|
||||
await writeFile(inputPath, pngBuffer);
|
||||
const { stdout } = await runPythonWithProgress(
|
||||
"face_landmarks.py",
|
||||
[inputPath, "unused", "{}"],
|
||||
|
||||
Reference in New Issue
Block a user