Merge branch 'dev' of https://github.com/Fairy-Oracle-Sanctuary/NeoBot into dev
This commit is contained in:
@@ -112,11 +112,11 @@ class ImageManager(Singleton):
|
||||
logger.exception(f"渲染模板 {template_name} 失败: {e}")
|
||||
return None
|
||||
|
||||
async def render_template_to_base64(self, template_name: str, data: Dict[str, Any], output_name: str = "output.png", quality: int = 80, image_type: str = "png") -> Optional[str]:
|
||||
async def render_template_to_base64(self, template_name: str, data: Dict[str, Any], output_name: str = "output.png", quality: int = 80, image_type: str = "png", width: int = 1920, height: int = 1080) -> Optional[str]:
|
||||
"""
|
||||
渲染模板并返回 Base64 编码的图片字符串
|
||||
"""
|
||||
file_path = await self.render_template(template_name, data, output_name, quality, image_type)
|
||||
file_path = await self.render_template(template_name, data, output_name, quality, image_type, width=width, height=height)
|
||||
if not file_path:
|
||||
return None
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ async def handle_weather(bot, event: MessageEvent, args: List[str]):
|
||||
try:
|
||||
# 渲染HTML模板为图片
|
||||
base64_image = await image_manager.render_template_to_base64(
|
||||
"weather.html", weather_info, output_name="weather.png"
|
||||
"weather.html", weather_info, output_name="weather.png", width=1080
|
||||
)
|
||||
|
||||
if base64_image:
|
||||
|
||||
Reference in New Issue
Block a user