|
11 | 11 | from pathlib import Path |
12 | 12 | from typing import ( |
13 | 13 | TYPE_CHECKING, |
| 14 | + Any, |
14 | 15 | Callable, |
15 | 16 | Dict, |
16 | 17 | Iterable, |
@@ -314,7 +315,7 @@ def show(page: Page, dpi: int = 72) -> Image.Image: |
314 | 315 | return next(convert(page, dpi=dpi)) |
315 | 316 |
|
316 | 317 |
|
317 | | -LabelFunc = Callable[[Union[Annotation, ContentObject, Element, Rect]], str] |
| 318 | +LabelFunc = Callable[[Union[Annotation, ContentObject, Element, Rect]], Any] |
318 | 319 | BoxFunc = Callable[[Union[Annotation, ContentObject, Element, Rect]], Rect] |
319 | 320 |
|
320 | 321 |
|
@@ -519,7 +520,7 @@ def box( |
519 | 520 | except ValueError: # it has no content and no box |
520 | 521 | continue |
521 | 522 | draw = ImageDraw.ImageDraw(image) |
522 | | - text = labelfunc(obj) |
| 523 | + text = str(labelfunc(obj)) |
523 | 524 | obj_color = make_color(text) |
524 | 525 | draw.rectangle((left, top, right, bottom), outline=obj_color) |
525 | 526 | if label: |
@@ -588,7 +589,7 @@ def mark( |
588 | 589 | except ValueError: # it has no content and no box |
589 | 590 | continue |
590 | 591 | draw = ImageDraw.ImageDraw(overlay) |
591 | | - text = labelfunc(obj) |
| 592 | + text = str(labelfunc(obj)) |
592 | 593 | obj_color = make_color(text) |
593 | 594 | draw.rectangle((left, top, right, bottom), fill=obj_color) |
594 | 595 | mask_draw = ImageDraw.ImageDraw(mask) |
|
0 commit comments