|
@@ 687-710 (lines=24) @@
|
| 684 |
|
|
| 685 |
|
alternative_image = None |
| 686 |
|
alternative_images = segment.get_AlternativeImage() |
| 687 |
|
if alternative_images: |
| 688 |
|
# (e.g. from segment-level cropping, binarization, deskewing or despeckling) |
| 689 |
|
if feature_selector or feature_filter: |
| 690 |
|
alternative_image = None |
| 691 |
|
# search from the end, because by convention we always append, |
| 692 |
|
# and among multiple satisfactory images we want the most recent: |
| 693 |
|
for alternative_image in reversed(alternative_images): |
| 694 |
|
features = alternative_image.get_comments() |
| 695 |
|
if (all(feature in features |
| 696 |
|
for feature in feature_selector.split(',') if feature) and |
| 697 |
|
not any(feature in features |
| 698 |
|
for feature in feature_filter.split(',') if feature)): |
| 699 |
|
break |
| 700 |
|
else: |
| 701 |
|
alternative_image = None |
| 702 |
|
else: |
| 703 |
|
alternative_image = alternative_images[-1] |
| 704 |
|
features = alternative_image.get_comments() |
| 705 |
|
if alternative_image: |
| 706 |
|
log.debug("Using AlternativeImage %d (%s) for segment '%s'", |
| 707 |
|
alternative_images.index(alternative_image) + 1, |
| 708 |
|
features, segment.id) |
| 709 |
|
segment_image = self._resolve_image_as_pil(alternative_image.get_filename()) |
| 710 |
|
segment_coords['features'] = features |
| 711 |
|
# transpose, if (still) necessary: |
| 712 |
|
if (orientation and |
| 713 |
|
not 'rotated-%d' % orientation in segment_coords['features'] and |
|
@@ 411-434 (lines=24) @@
|
| 408 |
|
|
| 409 |
|
alternative_image = None |
| 410 |
|
alternative_images = page.get_AlternativeImage() |
| 411 |
|
if alternative_images: |
| 412 |
|
# (e.g. from page-level cropping, binarization, deskewing or despeckling) |
| 413 |
|
if feature_selector or feature_filter: |
| 414 |
|
alternative_image = None |
| 415 |
|
# search from the end, because by convention we always append, |
| 416 |
|
# and among multiple satisfactory images we want the most recent: |
| 417 |
|
for alternative_image in reversed(alternative_images): |
| 418 |
|
features = alternative_image.get_comments() |
| 419 |
|
if (all(feature in features |
| 420 |
|
for feature in feature_selector.split(',') if feature) and |
| 421 |
|
not any(feature in features |
| 422 |
|
for feature in feature_filter.split(',') if feature)): |
| 423 |
|
break |
| 424 |
|
else: |
| 425 |
|
alternative_image = None |
| 426 |
|
else: |
| 427 |
|
alternative_image = alternative_images[-1] |
| 428 |
|
features = alternative_image.get_comments() |
| 429 |
|
if alternative_image: |
| 430 |
|
log.debug("Using AlternativeImage %d (%s) for page '%s'", |
| 431 |
|
alternative_images.index(alternative_image) + 1, |
| 432 |
|
features, page_id) |
| 433 |
|
page_image = self._resolve_image_as_pil(alternative_image.get_filename()) |
| 434 |
|
page_coords['features'] = features |
| 435 |
|
|
| 436 |
|
# crop, if (still) necessary: |
| 437 |
|
if (border and |