MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / crop_image

Function crop_image

scripts/icons_update.py:127–139  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

125 existing.add(fname)
126
127def crop_image(img):
128 w, h = img.size
129 if h == w:
130 return img
131 normal = min(h, w)
132 diff_w = w - normal
133 diff_h = h - normal
134 crop_top = diff_h // 2
135 crop_bot = diff_h // 2 + diff_h % 2
136 crop_left = diff_w // 2
137 crop_right = diff_w // 2 + diff_w % 2
138 box = (crop_left, crop_top, w - crop_right, h - crop_bot)
139 return img.crop(box)
140
141
142def get_icon_file(res_path, size):

Callers 1

get_icon_fileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected