Try img2pdf to generate the pdf
Issue : Xournal can't edit ??
This commit is contained in:
@@ -17,7 +17,8 @@ def detect_checks_and_notes(output_dir):
|
||||
notes_img: RGBA image of manual notes (checks masked out)
|
||||
"""
|
||||
pdf_path = os.path.join(output_dir, "Concat_annotated.pdf")
|
||||
ref_path = os.path.join(output_dir, "Reference.png")
|
||||
# ref_path = os.path.join(output_dir, "Reference.png")
|
||||
ref_path = os.path.join(output_dir, "Reference.jpg")
|
||||
json_path = os.path.join(output_dir, "checkboxes.json")
|
||||
|
||||
if not (os.path.exists(pdf_path) and os.path.exists(ref_path)):
|
||||
@@ -39,9 +40,7 @@ def detect_checks_and_notes(output_dir):
|
||||
except Exception as e:
|
||||
print(f"Error reading PDF: {e}")
|
||||
return [], None
|
||||
# print("Debug : user_pages", len(user_pages))
|
||||
# Concatenate PDF pages back to one image if user saved as multiple pages
|
||||
# (Xournal++ might preserve the long format or split it)
|
||||
total_h = sum(p.height for p in user_pages)
|
||||
user_img = Image.new("RGB", (user_pages[0].width, total_h))
|
||||
y = 0
|
||||
@@ -72,7 +71,7 @@ def detect_checks_and_notes(output_dir):
|
||||
DENSITY_THRESHOLD = 0.05 # 5% of pixels darkened
|
||||
|
||||
# Mask to hide checkmarks from the "Notes" extraction
|
||||
mask_img = Image.new("L", ref_img.size, 255) # White = keep, Black = hide
|
||||
mask_img = Image.new("L", ref_img.size, 255) # White (255) = keep, Black (0) = hide
|
||||
mask_draw = ImageDraw.Draw(mask_img)
|
||||
|
||||
for box in boxes:
|
||||
@@ -131,6 +130,12 @@ def detect_checks_and_notes(output_dir):
|
||||
|
||||
notes.putalpha(Image.fromarray(final_alpha))
|
||||
|
||||
# Debuging : Issues
|
||||
# - The artifacts increase as we go lower in the image
|
||||
# - Tous les rectangles sont présents
|
||||
# -
|
||||
notes.show()
|
||||
|
||||
return actions, notes
|
||||
|
||||
from PIL import ImageDraw
|
||||
|
||||
Reference in New Issue
Block a user