1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-23 06:31:54 +00:00

Fix crash when trying to crop blank images.

This commit is contained in:
neyney10
2024-10-18 17:23:57 +03:00
committed by Alex Xu
parent 4a661a1a17
commit 50eb48fb9b

View File

@@ -50,7 +50,10 @@ def get_bbox_crop_margin_page_number(img, power=1, background_color='white'):
''' '''
threshold = threshold_from_power(power) threshold = threshold_from_power(power)
bw_img = img.point(lambda p: 255 if p <= threshold else 0) bw_img = img.point(lambda p: 255 if p <= threshold else 0)
left, top_y_pos, right, bot_y_pos = bw_img.getbbox() bw_bbox = bw_img.getbbox()
if not bw_bbox: # bbox cannot be found in case that the entire resulted image is black.
return None
''' '''
We inspect the lower bottom part of the image where we suspect might be a page number. We inspect the lower bottom part of the image where we suspect might be a page number.