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

Function get_icon_file

scripts/icons_update.py:142–172  ·  view source on GitHub ↗

Get the iconFile field value and find proper icon for it. Return as PIL image object down- scaled for use in pyfa.

(res_path, size)

Source from the content-addressed store, hash-verified

140
141
142def get_icon_file(res_path, size):
143 """
144 Get the iconFile field value and find proper
145 icon for it. Return as PIL image object down-
146 scaled for use in pyfa.
147 """
148 res_path = res_path.lower()
149 res_path = res_path.replace('\\', '/')
150 res_path = res_path.replace('//', '/') #1703
151 if res_path not in res_index:
152 return None
153 res_icon = res_index[res_path]
154 icon_path = res_icon[1]
155
156 fullpath = os.path.join(res_cache, icon_path)
157
158 if not os.path.isfile(fullpath):
159 return None
160 img = Image.open(fullpath)
161
162 if size > img.size:
163 # if we are requesting a size that is bigger than the source, return None. See #1769
164 return None
165
166 img = crop_image(img)
167 img.thumbnail(size, Image.ANTIALIAS)
168
169 # Strip all additional image info (mostly for ICC color
170 # profiles, see issue #337)
171 img.info.clear()
172 return img
173
174
175toremove = existing.difference(needed)

Callers 1

icons_update.pyFile · 0.85

Calls 3

replaceMethod · 0.80
crop_imageFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected