From 3f20f4a3f4a914c907442e64d8b3023a82126cc7 Mon Sep 17 00:00:00 2001 From: Xintao Date: Thu, 25 Aug 2022 13:14:31 +0800 Subject: [PATCH] fix bug: crop supports gray image --- handyview/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handyview/utils.py b/handyview/utils.py index 32a1c99..43e614d 100644 --- a/handyview/utils.py +++ b/handyview/utils.py @@ -182,6 +182,7 @@ def crop_images(img_list, # draw rectangle if line_width > 0: - draw = ImageDraw.Draw(img) + img_rect = img.convert('RGB') + draw = ImageDraw.Draw(img_rect) draw.rectangle(((start_w, start_h), (start_w + len_w, start_h + len_h)), outline=color, width=line_width) - img.save(os.path.join(rect_folder, base_name + '_rect.png')) + img_rect.save(os.path.join(rect_folder, base_name + '_rect.png'))