<?php
require_once 'includes/auth.php';
require_once 'config/database.php';

header('Content-Type: application/json');

$image_id = filter_input(INPUT_GET, 'image_id', FILTER_VALIDATE_INT);
if (!$image_id) {
    echo json_encode(['error' => 'ID image manquant']);
    exit;
}

$pdo = getPDO();
$stmt = $pdo->prepare("SELECT annotations FROM fiches_images WHERE id = ?");
$stmt->execute([$image_id]);
$annotations = $stmt->fetchColumn();

if ($annotations) {
    echo $annotations;
} else {
    echo json_encode(['annotations' => null]);
}