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)
| 140 | |
| 141 | |
| 142 | def 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 | |
| 175 | toremove = existing.difference(needed) |
no test coverage detected