| 245 | |
| 246 | |
| 247 | class CachedReader: |
| 248 | def __init__(self, shared_dict=None): |
| 249 | if shared_dict: |
| 250 | self._cache = shared_dict |
| 251 | else: |
| 252 | self._cache = {} |
| 253 | |
| 254 | def open(self, fpath): |
| 255 | im = self._cache.get(fpath, None) |
| 256 | if im is None: |
| 257 | im = self._cache[fpath] = Image.open(fpath) |
| 258 | return im |
| 259 | |
| 260 | |
| 261 | class ImReader: |