master
Sébastien Miquel 2026-02-08 15:28:02 +01:00
parent 04045b0e9e
commit 690936a3f9
1 changed files with 6 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import json
import glob
from PIL import Image
MARGIN_LEFT = 200
# Results is : Copie id -> label -> {pdf_path, gemini_result, coordinates}
# Coordinates are the real coordinates (hmin, hmax) of the image in the Group
@ -201,8 +202,6 @@ def render_latex_text(text, width_px, bg_color=(255, 255, 255, 255), max_lines=N
def process_correction(root_dir, data, all_labels):
margin_left = 200
for student_id, labels in data.items():
# Prepare output directory: Dir/Anot_CopieID
@ -287,7 +286,7 @@ def process_correction(root_dir, data, all_labels):
total_height = base_img.height + header_height
# Create Canvas
final_img = Image.new("RGB", (base_img.width + margin_left, total_height), "white")
final_img = Image.new("RGB", (base_img.width + MARGIN_LEFT, total_height), "white")
# Paste Headers
current_y = 0
@ -298,7 +297,7 @@ def process_correction(root_dir, data, all_labels):
# Paste Original Image
# Note: current_y is now the offset for the actual image content
image_offset_y = current_y
final_img.paste(base_img, (margin_left, image_offset_y))
final_img.paste(base_img, (MARGIN_LEFT, image_offset_y))
# --- DRAW LOCAL ANNOTATIONS ---
draw = ImageDraw.Draw(final_img, "RGBA")
@ -315,8 +314,8 @@ def process_correction(root_dir, data, all_labels):
target_ymin = (ymin - hmin) + image_offset_y
target_ymax = (ymax - hmin) + image_offset_y
target_xmin = xmin + margin_left
target_xmax = xmax + margin_left
target_xmin = xmin + MARGIN_LEFT
target_xmax = xmax + MARGIN_LEFT
# Draw Rectangle
draw.rectangle([target_xmin, target_ymin, target_xmax, target_ymax], outline="red", width=3)
@ -325,7 +324,7 @@ def process_correction(root_dir, data, all_labels):
# (255, 0, 0, 50) is transparent red
txt_img = render_latex_text(
fb['text'],
width_px=500,
width_px=600,
bg_color=(255, 200, 200, 180), # Light Red semi-transparent
max_lines=3
)