#!/usr/bin/env python3
"""测试图片生成器"""

import sys
from pathlib import Path

PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT))

from scripts.image_generator import ImageGenerator

def main():
    print("开始测试图片生成...")
    generator = ImageGenerator()
    print(f"输出目录: {generator.output_dir}")
    
    try:
        files = generator.generate_all_placeholders("测试文章标题：上海阳台种菜一年", "zhihu")
        print(f"✅ 成功生成 {len(files)} 张图片:")
        for name, path in files.items():
            size_kb = path.stat().st_size // 1024
            print(f"  - {name}: {path.name} ({size_kb}KB)")
        print(f"图片保存在: {generator.output_dir}")
        return 0
    except Exception as e:
        print(f"❌ 生成失败: {e}")
        import traceback
        traceback.print_exc()
        return 1

if __name__ == "__main__":
    sys.exit(main())