self-media-james/scripts/gen_article_images.py
邓文兵 a7fc0ed3bb feat(article): 为开源龙虾全家桶文章添加配图和生成脚本
- 在文章中添加了封面、OpenClaw、Nanobot、PicoClaw、ZeroClaw、memU等多个配图
- 新增中国龙虾军团、LobsterAI、Agent TARS、选龙虾指南和安全警示等配图
- 创建scripts/gen_article_images.py批量生成文章配图的脚本
- 实现即梦AI图片生成工具jimeng_gen.py,支持文生图功能
- 配置API密钥和签名算法,实现图片生成任务提交和轮询机制
2026-03-10 13:43:56 +08:00

111 lines
4.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""批量生成龙虾全家桶文章配图"""
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
from jimeng_gen import generate_image
BASE_DIR = os.path.join(os.path.dirname(__file__), '..', 'images', '001')
IMAGES = [
{
"name": "cover.png",
"prompt": "一群风格各异的卡通龙虾站在巨大的发光电路板上每只龙虾颜色不同有红色、蓝色、绿色、金色、紫色背景是深蓝色科技感数据流中间有一个大大的开源符号扁平插画风格色彩鲜艳充满活力16:9构图",
"width": 1280,
"height": 720,
},
{
"name": "openclaw_hero.png",
"prompt": "一只巨大的红色卡通龙虾坐在服务器机房的中控台前面前有多个全息屏幕显示着WhatsApp、Slack、Telegram的图标龙虾戴着耳机在工作科技感赛博朋克风格蓝紫色调",
"width": 1024,
"height": 1024,
},
{
"name": "nanobot.png",
"prompt": "一只迷你的白色卡通龙虾站在一本打开的Python编程书上身体非常小巧精致旁边有一个放大镜上面写着4000极简风格白色背景干净利落扁平插画",
"width": 1024,
"height": 1024,
},
{
"name": "picoclaw.png",
"prompt": "一只微型绿色卡通龙虾站在一块很小的电路板芯片上,芯片发着绿色的光,旁边放着一枚硬币做大小对比,背景是智能家居场景,温暖的灯光,科技与居家结合的风格",
"width": 1024,
"height": 1024,
},
{
"name": "zeroclaw.png",
"prompt": "一只银色金属质感的卡通龙虾身穿铠甲,手持盾牌,盾牌上有一个锁的图标,站在数字城堡的城门前,背景是防火墙的数据流,安全感十足,金属蓝色调,科幻风格",
"width": 1024,
"height": 1024,
},
{
"name": "memu.png",
"prompt": "一只紫色卡通龙虾的大脑上方浮现着发光的知识图谱网络,各个节点之间有彩色连线,节点上有小图标代表日历、音乐、跑步、生日蛋糕等生活场景,深色背景,科技紫色调,梦幻风格",
"width": 1024,
"height": 1024,
},
{
"name": "china_lobsters.png",
"prompt": "五只不同颜色的卡通龙虾站在中国风格的舞台上,背景有网易、阿里巴巴、腾讯、字节跳动的抽象标志元素,舞台上有红色灯笼和科技全息投影的结合,中国红与科技蓝的碰撞,喜庆又现代",
"width": 1280,
"height": 720,
},
{
"name": "lobsterai.png",
"prompt": "一只金色卡通龙虾面前有一个漂亮的图形化操作界面界面上显示着中文龙虾用钳子在触摸屏上操作旁边有DeepSeek的logo标志现代化办公室背景明亮温暖的色调",
"width": 1024,
"height": 1024,
},
{
"name": "agent_tars.png",
"prompt": "一只机械风格的卡通龙虾坐在电脑前它的眼睛发出扫描光线照在电脑屏幕上钳子在键盘上打字屏幕上显示着被高亮框选的GUI元素未来感十足暗色调配霓虹灯效果",
"width": 1024,
"height": 1024,
},
{
"name": "choose_guide.png",
"prompt": "一个可爱的卡通场景:一个人站在龙虾水族馆前,玻璃缸里有各种不同颜色和大小的龙虾,每只龙虾上方有小标签,人物在思考选择哪只,温馨有趣的插画风格,明亮色彩",
"width": 1280,
"height": 720,
},
{
"name": "security_warning.png",
"prompt": "一只卡通龙虾拿着一个警告三角标志,旁边有一个打开的插件盒子,里面冒出可疑的紫色烟雾,背景是安全警示条纹,黄色和黑色配色,警示感强烈但不失可爱",
"width": 1024,
"height": 1024,
},
]
def main():
os.makedirs(BASE_DIR, exist_ok=True)
results = []
for i, img in enumerate(IMAGES):
output_path = os.path.join(BASE_DIR, img["name"])
if os.path.exists(output_path):
print(f"[{i+1}/{len(IMAGES)}] 跳过已存在: {img['name']}")
results.append(output_path)
continue
print(f"\n[{i+1}/{len(IMAGES)}] 生成: {img['name']}")
result = generate_image(
prompt=img["prompt"],
output_path=output_path,
width=img.get("width", 1024),
height=img.get("height", 1024),
)
if result:
results.append(result)
else:
print(f" !! 生成失败: {img['name']}")
print(f"\n===== 完成 =====")
print(f"成功: {len(results)}/{len(IMAGES)}")
for r in results:
print(f"{r}")
if __name__ == '__main__':
main()