MCPcopy Create free account
hub / github.com/AiuniAI/Unique3D / expand2square

Function expand2square

scripts/utils.py:268–279  ·  view source on GitHub ↗
(pil_img, background_color)

Source from the content-addressed store, hash-verified

266
267
268def expand2square(pil_img, background_color):
269 width, height = pil_img.size
270 if width == height:
271 return pil_img
272 elif width > height:
273 result = Image.new(pil_img.mode, (width, width), background_color)
274 result.paste(pil_img, (0, (width - height) // 2))
275 return result
276 else:
277 result = Image.new(pil_img.mode, (height, height), background_color)
278 result.paste(pil_img, ((height - width) // 2, 0))
279 return result
280
281
282def simple_preprocess(input_image, rembg_session=session, background_color=255):

Callers 1

simple_preprocessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected