Fix modifying header height

This commit is contained in:
2026-03-10 14:58:47 +01:00
parent 95f20eb8b7
commit a658cb72e0
2 changed files with 33 additions and 6 deletions
+13 -2
View File
@@ -255,7 +255,7 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
(base_img, _, _) = annotating.make_base_image(pdf_path)
# Compose uses the result object we modified in step 1
final_img, _ = annotating.compose_label_image(
final_img, new_header_h = annotating.compose_label_image(
base_img, label, content['result'], content['coordinates'][0],
with_error=False
)
@@ -264,7 +264,18 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
# Overlay manual notes
if has_notes:
final_img.paste(sub_note, (0, 0), mask=sub_note)
old_header_h = int(img_info.get("header_height", 0))
w, h = sub_note.size
# 1. Paste header ink at the top
if old_header_h > 0:
header_crop = sub_note.crop((0, 0, w, min(h, old_header_h)))
final_img.paste(header_crop, (0, 0), mask=header_crop)
# 2. Paste student-content ink at the new header height
if h > old_header_h:
body_crop = sub_note.crop((0, old_header_h, w, h))
final_img.paste(body_crop, (0, new_header_h), mask=body_crop)
# C. Save individual file if Modified (Dirty logic or visual notes)
if (label in dirty_labels) or has_notes: