fix:修改敏感数据
This commit is contained in:
28
utils/image_utils.py
Normal file
28
utils/image_utils.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
|
||||
|
||||
def find_image_path(folder, base_filename):
|
||||
"""
|
||||
在指定文件夹中查找图片,支持 jpg/jpeg/png 等多种后缀。
|
||||
:param folder: 文件夹路径
|
||||
:param base_filename: 基础文件名(不带后缀,例如 "1" 或 "me_image")
|
||||
:return: 找到的完整文件路径,如果没找到则返回 None
|
||||
"""
|
||||
if not os.path.exists(folder):
|
||||
return None
|
||||
|
||||
# 支持的后缀列表 (包含大小写)
|
||||
extensions = [
|
||||
".jpg", ".JPG",
|
||||
".jpeg", ".JPEG",
|
||||
".png", ".PNG",
|
||||
".bmp", ".BMP"
|
||||
]
|
||||
|
||||
for ext in extensions:
|
||||
# 拼凑完整路径,例如 data/images/张三/1.png
|
||||
full_path = os.path.join(folder, base_filename + ext)
|
||||
if os.path.exists(full_path):
|
||||
return full_path
|
||||
|
||||
return None
|
||||
Reference in New Issue
Block a user