MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / crop_image

Function crop_image

scripts/renders_update.py:61–73  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

59
60
61def crop_image(img):
62 w, h = img.size
63 if h == w:
64 return img
65 normal = min(h, w)
66 diff_w = w - normal
67 diff_h = h - normal
68 crop_top = diff_h // 2
69 crop_bot = diff_h // 2 + diff_h % 2
70 crop_left = diff_w // 2
71 crop_right = diff_w // 2 + diff_w % 2
72 box = (crop_left, crop_top, w - crop_right, h - crop_bot)
73 return img.crop(box)
74
75
76def get_render(type_id):

Callers 1

get_renderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected