self-media-james/.claude/commands/generate-image.md
邓文兵 fdf5cc278f feat(article): 更新文章内容并集成CDN图片上传功能
- 将文章中的本地图片路径替换为CDN链接
- 修改文章引子部分,更新案例描述和内容细节
- 添加即梦AI图片生成命令配置文件
- 添加七牛云OSS上传命令配置文件和上传脚本
- 创建七牛云存储凭证文档
- 更新OpenClaw相关内容和图片引用链接
2026-03-10 18:00:32 +08:00

55 lines
1.5 KiB
Markdown
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.

# 即梦 AI 图片生成
使用即梦 AI火山引擎生成图片。
## 使用方式
用户会提供:
1. **prompt**:图片描述(中文)
2. **output_path**:输出路径(可选,默认保存到当前工作目录)
## 执行步骤
1. 激活项目虚拟环境:`source .venv/bin/activate`
2. 调用 `scripts/jimeng_gen.py` 生成图片
3. 即梦 API 仅支持 **1024x1024** 正方形尺寸
4. 如果用户需要 16:9 比例,先生成 1024x1024再用 Pillow 居中裁剪为 1024x576
5. 展示生成的图片给用户
## 调用示例
```bash
source .venv/bin/activate && python scripts/jimeng_gen.py "图片描述prompt" "输出路径.png"
```
## 16:9 裁剪(如需要)
```bash
source .venv/bin/activate && python -c "
from PIL import Image
img = Image.open('输出路径.png')
w, h = img.size
new_h = int(w * 9 / 16)
top = (h - new_h) // 2
img.crop((0, top, w, top + new_h)).save('输出路径.png')
"
```
## 注意事项
- 即梦 API **仅支持 1024x1024**,其他尺寸会提交成功但生成失败
- 需要非正方形图片时,先生成方形再裁剪
- 提交后需要轮询等待结果,通常 5-10 秒完成
- 脚本位于 `scripts/jimeng_gen.py`,密钥已内置
- 虚拟环境位于 `.venv/`,已安装 `requests``Pillow`
## API 凭证(已内置于脚本)
- Endpoint: `https://visual.volcengineapi.com`
- Region: `cn-north-1`
- Service: `cv`
- 模型: `jimeng_t2i_v40`(即梦图片生成 4.0
- 签名: HMAC-SHA256 V4
$ARGUMENTS