feat(plugins): 调整天气图片渲染尺寸
This commit is contained in:
@@ -112,11 +112,11 @@ class ImageManager(Singleton):
|
|||||||
logger.exception(f"渲染模板 {template_name} 失败: {e}")
|
logger.exception(f"渲染模板 {template_name} 失败: {e}")
|
||||||
return None
|
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 编码的图片字符串
|
渲染模板并返回 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:
|
if not file_path:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ async def handle_weather(bot, event: MessageEvent, args: List[str]):
|
|||||||
try:
|
try:
|
||||||
# 渲染HTML模板为图片
|
# 渲染HTML模板为图片
|
||||||
base64_image = await image_manager.render_template_to_base64(
|
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:
|
if base64_image:
|
||||||
|
|||||||
Reference in New Issue
Block a user