(self, image_path)
| 58 | return base64.b64encode(buffered.getvalue()).decode("utf-8") |
| 59 | |
| 60 | def _get_cached_base64(self, image_path): |
| 61 | with self._cache_lock: |
| 62 | cached = self._encode_cache.get(image_path) |
| 63 | if cached is not None: |
| 64 | return cached |
| 65 | encoded = self._encode_image(image_path) |
| 66 | with self._cache_lock: |
| 67 | if len(self._encode_cache) >= self.max_cache_items: |
| 68 | self._encode_cache.clear() |
| 69 | self._encode_cache[image_path] = encoded |
| 70 | return encoded |
| 71 | |
| 72 | def build_messages(self, item, image_root=None): |
| 73 | content = [] |
no test coverage detected