Unverified Commit 0c457bae authored by isaac-vidas's avatar isaac-vidas Committed by GitHub
Browse files

Handle grayscale images in expand2square (#97)

parent d3fc86a4
......@@ -163,7 +163,9 @@ def expand2square(pil_img, background_color):
width, height = pil_img.size
if width == height:
return pil_img
elif width > height:
if pil_img.mode == "L":
pil_img = pil_img.convert("RGB")
if width > height:
result = Image.new(pil_img.mode, (width, width), background_color)
result.paste(pil_img, (0, (width - height) // 2))
return result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment