Fix modifying header height
This commit is contained in:
+13
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user