markup: process Documents inklist annotations

This commit is contained in:
2020-02-28 16:23:33 -08:00
parent 8a1b94b4dc
commit 97ef16e47a
3 changed files with 76 additions and 9 deletions

View File

@ -110,3 +110,22 @@ def write_debug_image(workdir, page_num, prods, scribbles):
img.save(path)
set_file_perms(path)
def write_inklist(obj, path):
"""Draw an image of the inklist."""
pagew = int(11*72)
pageh = int(8.5*72)
img = Image.new('RGBA', (pagew, pageh), (0, 0, 0, 0))
draw = ImageDraw.Draw(img, 'RGBA')
for segment in obj['InkList']:
draw.line(segment, 'black', 3)
# account for the difference in coordinate systems
# between pdf and images.
img = img.transpose(Image.FLIP_TOP_BOTTOM)
img.save(path)
set_file_perms(path)