Improve how images are centered for better face detection

Update the AI prompt to more accurately detect focal points in images, ensuring faces are centered correctly within the frame.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: a81de0df-cbab-410b-b11a-e64ca9ee578b
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/0ZGabQy
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sebastjanartic 2026-02-28 21:37:40 +00:00
parent 222dd940b9
commit b1bd37d66e
3 changed files with 9 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

View File

@ -13,12 +13,15 @@ const SYSTEM_PROMPT = `You are an image analysis tool that detects where faces a
Analyze the image and find the PRIMARY person or group of people. Report the CENTER of their face(s) as x,y percentages.
- x=0 means far left edge, x=100 means far right edge
- y=0 means very top edge, y=100 means very bottom edge
- For a person's face in the upper third, y should be around 15-35
- For a person standing centered, x should be around 40-60
- For a group photo, find the center of the group's faces
- Be PRECISE, do NOT default to 50,50. Actually look at where faces are.
- If there are multiple people, find the most prominent face or group center.
Return ONLY a JSON object like {"x":42,"y":28} with no other text.`;
- Think carefully: divide the image into a 10x10 grid and locate faces precisely
- For a typical portrait where a person is standing, faces are usually at y=25-40
- For a group photo with people standing, the faces are usually at y=30-45
- For a close-up headshot, the face center is usually at y=40-55
- For people sitting at a table, faces are usually at y=35-50
- Do NOT assume faces are at the very top. Faces are rarely below y=20 unless it's a very tight crop.
- Be PRECISE. Actually look at where the eyes/faces are in the image.
- If there are multiple people, find the center point of ALL their faces.
Return ONLY a JSON object like {"x":42,"y":38} with no other text.`;
export async function analyzeFocalPoint(imagePath: string): Promise<{ x: number; y: number }> {
const originalPath = imagePath;