Adjust image focal points to better display subjects

Manually override image focal point analysis for specific images to ensure proper centering and visibility of subjects.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: b4c7dff0-e78c-4ca9-ab54-125899290a36
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:47:02 +00:00
parent e3c818f8c0
commit 3052260e84

View File

@ -9,6 +9,10 @@ const openai = new OpenAI({
const cache = new Map<string, { x: number; y: number }>();
const manualOverrides: Record<string, { x: number; y: number }> = {
"/uploads/70-jahre-oberkrainer.webp": { x: 50, y: 55 },
};
const SYSTEM_PROMPT = `You are an image analysis tool that detects where faces and people are located in photographs.
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
@ -25,6 +29,10 @@ 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;
if (manualOverrides[originalPath]) {
cache.set(originalPath, manualOverrides[originalPath]);
return manualOverrides[originalPath];
}
if (cache.has(originalPath)) {
return cache.get(originalPath)!;
}