markup: handle netpbm encoded annotations
This commit is contained in:
@ -20,12 +20,16 @@ def find_shapes(image_path):
|
||||
"""
|
||||
path = Path(image_path)
|
||||
|
||||
img = Image.open(image_path, 'r')
|
||||
if not img.mode in ('RGBA', 'LA'):
|
||||
print('no alpha channel: {}'.format(img.mode))
|
||||
return None
|
||||
print('finding shapes in {}'.format(image_path))
|
||||
|
||||
alpha_layer = img.convert('RGBA').split()[-1]
|
||||
img = Image.open(image_path, 'r')
|
||||
if img.mode == 'RGBA':
|
||||
alpha_layer = img.convert('RGBA').split()[-1]
|
||||
elif img.mode == 'L':
|
||||
alpha_layer = img
|
||||
else:
|
||||
print('unhandled image mode: {}'.format(img.mode))
|
||||
return None
|
||||
|
||||
alpha_layer = alpha_layer.filter(ImageFilter.GaussianBlur(5))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user