Borner la mémoire de la carte (OOM du Pi) et rallumer le relief orienté par défaut
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -588,11 +588,16 @@ def _open_source(path_str, mtime):
|
||||
if img is not None:
|
||||
_source_cache.move_to_end(key)
|
||||
return img
|
||||
img = Image.open(str(path_str))
|
||||
img.load()
|
||||
if img.mode not in ("RGB", "RGBA"):
|
||||
img = img.convert("RGB")
|
||||
size = img.size[0] * img.size[1] * len(img.getbands())
|
||||
# Copie détachée du fichier : une image AVIF ouverte garde son décodeur
|
||||
# (tampons libavif/dav1d, ~18 Mo par quadrant 2500²) tant qu'elle vit —
|
||||
# en cache, cela doublait la mémoire réelle et faisait tuer le conteneur
|
||||
# du Pi (1 Go) par l'OOM killer en navigation à fort zoom.
|
||||
with Image.open(str(path_str)) as opened:
|
||||
opened.load()
|
||||
img = (opened.copy() if opened.mode in ("RGB", "RGBA")
|
||||
else opened.convert("RGB"))
|
||||
# PIL stocke RGB comme RGBA : 4 octets par pixel dans les deux cas.
|
||||
size = img.size[0] * img.size[1] * 4
|
||||
with _source_cache_lock:
|
||||
_source_cache[key] = img
|
||||
_source_cache[key].info["_bytes"] = size
|
||||
|
||||
Reference in New Issue
Block a user