新增模板预览功能
This commit is contained in:
@@ -76,6 +76,20 @@
|
||||
"template.modern": "Modern",
|
||||
"template.neon": "Neon",
|
||||
"template.custom_help": "💡 Custom: Place .html files in templates/ folder",
|
||||
"template.preview_title": "🔍 Preview Template",
|
||||
"template.preview_param_title": "Title",
|
||||
"template.preview_param_text": "Text",
|
||||
"template.preview_param_image": "Image Path",
|
||||
"template.preview_param_width": "Width",
|
||||
"template.preview_param_height": "Height",
|
||||
"template.preview_default_title": "AI Changes Content Creation",
|
||||
"template.preview_default_text": "Artificial intelligence is transforming the way we create content, making it easy for everyone to produce professional-grade videos.",
|
||||
"template.preview_button": "🖼️ Generate Preview",
|
||||
"template.preview_generating": "Generating template preview...",
|
||||
"template.preview_success": "✅ Preview generated successfully!",
|
||||
"template.preview_failed": "❌ Preview failed: {error}",
|
||||
"template.preview_image_help": "Supports local path or URL",
|
||||
"template.preview_caption": "Template Preview: {template}",
|
||||
|
||||
"video.title": "🎬 Video Settings",
|
||||
"video.frames": "Scenes",
|
||||
|
||||
@@ -76,6 +76,20 @@
|
||||
"template.modern": "现代",
|
||||
"template.neon": "霓虹",
|
||||
"template.custom_help": "💡 自定义:将 .html 文件放入 templates/ 文件夹",
|
||||
"template.preview_title": "🔍 预览模板",
|
||||
"template.preview_param_title": "标题",
|
||||
"template.preview_param_text": "文本",
|
||||
"template.preview_param_image": "图片路径",
|
||||
"template.preview_param_width": "宽度",
|
||||
"template.preview_param_height": "高度",
|
||||
"template.preview_default_title": "AI 改变内容创作",
|
||||
"template.preview_default_text": "人工智能正在改变内容创作的方式,让每个人都能轻松制作专业级视频。",
|
||||
"template.preview_button": "🖼️ 生成预览",
|
||||
"template.preview_generating": "正在生成模板预览...",
|
||||
"template.preview_success": "✅ 预览生成成功!",
|
||||
"template.preview_failed": "❌ 预览失败:{error}",
|
||||
"template.preview_image_help": "支持本地路径或 URL",
|
||||
"template.preview_caption": "模板预览:{template}",
|
||||
|
||||
"video.title": "🎬 视频设置",
|
||||
"video.frames": "分镜数",
|
||||
|
||||
@@ -206,7 +206,7 @@ class HTMLFrameGenerator:
|
||||
Args:
|
||||
title: Video title
|
||||
text: Narration text for this frame
|
||||
image: Path to AI-generated image
|
||||
image: Path to AI-generated image (supports relative path, absolute path, or HTTP URL)
|
||||
ext: Additional data (content_title, content_author, etc.)
|
||||
width: Frame width in pixels
|
||||
height: Frame height in pixels
|
||||
@@ -214,6 +214,22 @@ class HTMLFrameGenerator:
|
||||
Returns:
|
||||
Path to generated frame image
|
||||
"""
|
||||
# Convert image path to absolute path or file:// URL for html2image
|
||||
if image and not image.startswith(('http://', 'https://', 'data:', 'file://')):
|
||||
# Local file path - convert to absolute path and file:// URL
|
||||
image_path = Path(image)
|
||||
if not image_path.is_absolute():
|
||||
# Relative to current working directory (project root)
|
||||
image_path = Path.cwd() / image
|
||||
|
||||
# Ensure the file exists
|
||||
if not image_path.exists():
|
||||
logger.warning(f"Image file not found: {image_path}")
|
||||
else:
|
||||
# Convert to file:// URL for html2image compatibility
|
||||
image = image_path.as_uri()
|
||||
logger.debug(f"Converted image path to: {image}")
|
||||
|
||||
# Build variable context
|
||||
context = {
|
||||
# Required variables
|
||||
|
||||
Reference in New Issue
Block a user