Handle grayscale images in expand2square (#97)
This commit is contained in:
@@ -163,7 +163,9 @@ def expand2square(pil_img, background_color):
|
|||||||
width, height = pil_img.size
|
width, height = pil_img.size
|
||||||
if width == height:
|
if width == height:
|
||||||
return pil_img
|
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 = Image.new(pil_img.mode, (width, width), background_color)
|
||||||
result.paste(pil_img, (0, (width - height) // 2))
|
result.paste(pil_img, (0, (width - height) // 2))
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user