Skip to content

Commit dedb56e

Browse files
author
Robert Sachunsky
committed
clip: keep alpha channel if already present
1 parent a6f90ab commit dedb56e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ocrd_cis/ocropy/clip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def process(self):
128128
else:
129129
background = background.median[0]
130130
if level == 'region':
131-
background_image = Image.new('L', page_image.size, background)
131+
background_image = Image.new(page_image.mode, page_image.size, background)
132132
page_array = pil2array(page_image)
133133
page_bin = np.array(page_array <= midrange(page_array), np.uint8)
134134
# in absolute coordinates merely for comparison/intersection
@@ -172,7 +172,7 @@ def process(self):
172172
continue
173173
region_image, region_coords = self.workspace.image_from_segment(
174174
region, page_image, page_coords, feature_selector='binarized')
175-
background_image = Image.new('L', region_image.size, background)
175+
background_image = Image.new(region_image.mode, region_image.size, background)
176176
region_array = pil2array(region_image)
177177
region_bin = np.array(region_array <= midrange(region_array), np.uint8)
178178
# in absolute coordinates merely for comparison/intersection

0 commit comments

Comments
 (0)