Resolve uploaded image references for prompt enhancement
This commit is contained in:
@@ -1410,7 +1410,12 @@ def _restore_qwen(profile: str) -> None:
|
||||
|
||||
def _image_data_url(path: str) -> str:
|
||||
"""Read one already validated local reference image as a data URL."""
|
||||
with open(path, "rb") as handle:
|
||||
image_root = os.path.abspath(IMAGE_DIR)
|
||||
resolved = (os.path.abspath(path) if os.path.isabs(path)
|
||||
else os.path.abspath(os.path.join(image_root, path)))
|
||||
if os.path.commonpath((image_root, resolved)) != image_root:
|
||||
raise RuntimeError("Referenzbild liegt außerhalb des Bildverzeichnisses")
|
||||
with open(resolved, "rb") as handle:
|
||||
data = handle.read()
|
||||
if data.startswith(b"\x89PNG\r\n\x1a\n"):
|
||||
mime = "image/png"
|
||||
|
||||
Reference in New Issue
Block a user