Fix review snapshots without handwriting images

This commit is contained in:
sebastien committed 2026-11-03 09:30:50 +01:00
1 parent 5dd0dd2ce9
commit fd943696fb
2 files changed
+33 -3

No files matched your search

+8 -2
View File
@@ -45,8 +45,11 @@ def stage(output, staging, data, notes, *, engine, bnote=None, selected=None, fo
merged_notes.pop(label, None)
note = notes.get(label)
if note is not None:
filename = '.review-note-' + sha256(label.encode()).hexdigest() + '.png'
note['img'].save(staging / filename)
# Grouped scans retain layout metadata even without handwriting.
filename = None
if note['img'] is not None:
filename = '.review-note-' + sha256(label.encode()).hexdigest() + '.png'
note['img'].save(staging / filename)
merged_notes[label] = {k: v for k, v in note.items() if k != 'img'} | {'file': filename}
payload = {'version': 1, 'engine': engine, 'data': merged_data, 'notes': merged_notes, 'bnote': bnote, 'force_filtered': sorted(retained)}
# Roundtrip normalizes tuples while rejecting unsupported rendering data.
@@ -64,6 +67,9 @@ def load(root, output):
notes = {}
for label, metadata in saved['notes'].items():
filename = metadata['file']
if filename is None:
notes[label] = {k: v for k, v in metadata.items() if k != 'file'} | {'img': None}
continue
if Path(filename).name != filename:
raise ValueError('Image manuscrite invalide.')
with Image.open(output / filename) as image: