Compare commits
1 Commits
3a87751444
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e55daf275e |
@@ -27,6 +27,36 @@ if str(_REPO_ROOT) not in sys.path:
|
||||
import streamlit as st
|
||||
from PIL import Image
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Compatibility shim : streamlit-drawable-canvas 0.9.3 utilise l'API privée
|
||||
# `streamlit.elements.image.image_to_url` qui a été retirée à partir de
|
||||
# Streamlit ≈ 1.49. On réinjecte une implémentation équivalente fondée sur
|
||||
# un data URI base64, ce qui permet au canvas de continuer à fonctionner
|
||||
# sans downgrader Streamlit globalement.
|
||||
#
|
||||
# Remplacer ce shim par l'upgrade de streamlit-drawable-canvas si une version
|
||||
# > 0.9.3 est publiée.
|
||||
# ----------------------------------------------------------------------------
|
||||
import base64 as _b64
|
||||
import io as _io
|
||||
from streamlit.elements import image as _st_image # type: ignore
|
||||
|
||||
if not hasattr(_st_image, "image_to_url"):
|
||||
def _image_to_url_compat(image, width, clamp, channels, output_format,
|
||||
image_id):
|
||||
"""Convertit une PIL.Image en data URI compatible avec drawable-canvas."""
|
||||
fmt = (output_format or "PNG").upper()
|
||||
if fmt == "JPG":
|
||||
fmt = "JPEG"
|
||||
buf = _io.BytesIO()
|
||||
image.save(buf, format=fmt)
|
||||
b64 = _b64.b64encode(buf.getvalue()).decode("ascii")
|
||||
mime = "image/jpeg" if fmt == "JPEG" else f"image/{fmt.lower()}"
|
||||
return f"data:{mime};base64,{b64}"
|
||||
|
||||
_st_image.image_to_url = _image_to_url_compat # type: ignore[attr-defined]
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
from pipeline.ingest import pdf_to_images
|
||||
from pipeline.zones_config import load_config, save_config, DEFAULT_CONFIG_PATH
|
||||
|
||||
|
||||
Reference in New Issue
Block a user