Fix review snapshots without handwriting images
This commit is contained in:
1 parent
5dd0dd2ce9
commit
fd943696fb
2 files changed
+33
-3
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user