Skip to content

Commit 998c1a4

Browse files
author
Robert Sachunsky
committed
clip: fix bg tuple vs scalar (depending on mode)
1 parent 4f3947d commit 998c1a4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ocrd_cis/ocropy/clip.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ def process(self):
121121
page.get_UnknownRegion())
122122
if not num_texts:
123123
LOG.warning('Page "%s" contains no text regions', page_id)
124-
background = ImageStat.Stat(page_image).median[0]
124+
background = ImageStat.Stat(page_image)
125+
# workaround for Pillow#4925
126+
if len(background.bands) > 1:
127+
background = tuple(background.median)
128+
else:
129+
background = background.median[0]
125130
if level == 'region':
126131
background_image = Image.new('L', page_image.size, background)
127132
page_array = pil2array(page_image)

0 commit comments

Comments
 (0)