From eb47ab4fe6be3266168d6bd0c7d68f39709fb24c Mon Sep 17 00:00:00 2001 From: jeremygan2021 Date: Wed, 26 Nov 2025 21:13:34 +0800 Subject: [PATCH] =?UTF-8?q?docker=20=E5=8A=A8=E6=80=81=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E8=B0=83=E7=94=A8tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/contents.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/contents.py b/api/contents.py index 4a3e7f2..9e4e1f3 100644 --- a/api/contents.py +++ b/api/contents.py @@ -357,8 +357,15 @@ def convert_to_binary_data(image_path: str, width: int = 400, height: int = 300, 二进制数据 """ try: - # 动态导入image_converter模块 - spec = importlib.util.spec_from_file_location("image_converter", "/Users/jeremygan/Desktop/python_dev/luna2025/tool/image_converter.py") + # 动态导入image_converter模块 - 使用相对路径 + import os + # 获取当前文件的目录 + current_dir = os.path.dirname(os.path.abspath(__file__)) + # 构建到tool目录的路径 + tool_dir = os.path.join(current_dir, "..", "tool") + image_converter_path = os.path.join(tool_dir, "image_converter.py") + # 导入模块 + spec = importlib.util.spec_from_file_location("image_converter", image_converter_path) image_converter = importlib.util.module_from_spec(spec) spec.loader.exec_module(image_converter)