codex-images

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codex Images

Codex 图片生成

Images made by Codex's built-in image tool, run from the terminal: one
codex exec
per image, several at once. It uses their ChatGPT plan (Plus or Pro), no API key.
Talk to them in their language.
<out>
= the output folder:
video-agent/edits/<slug>/images/
for a video, else
video-agent/images/<name>/
.
通过 terminal 运行 Codex 内置的 image tool 生成图片:每张图片运行一次
codex exec
,可同时运行多个。它使用用户的 ChatGPT 套餐(Plus 或 Pro),无需 API key。
始终使用用户所用的语言进行沟通。
<out>
= 输出文件夹:视频使用
video-agent/edits/<slug>/images/
,其他情况使用
video-agent/images/<name>/
。

1. Codex (once)

1. Codex(一次性操作)

bash
codex --version
codex login status
  • Not installed:
    npm i -g @openai/codex
    (needs Node 20+), or
    brew install codex
    on macOS.
  • Not logged in: they run
    codex login
    themselves (it opens the browser, "Sign in with ChatGPT"). Never ask for an OpenAI key or password in the chat.
bash
codex --version
codex login status
  • 未安装:运行
    npm i -g @openai/codex
    (需要 Node 20+),或在 macOS 上运行
    brew install codex
    。
  • 未登录:由用户自行运行
    codex login
    (这会打开浏览器并显示“Sign in with ChatGPT”)。切勿在聊天中索要 OpenAI key 或密码。

2. The brief

2. 创作简报

One image = one prompt. Never pack several ideas into one job.
Ask only what is missing, in one message:
  • What for: thumbnail (1280x720, 16:9), short cover (1080x1920, 9:16), square post (1:1), a still for a callout or B-roll (the video's format).
  • How many: 1 by default; 3 variants for a thumbnail (a different idea each, not the same one three times).
  • Their face: a thumbnail with them in it needs 1 to 3 clear photos (a frame of a take works:
    ffmpeg -v error -y -ss <t> -i <take> -frames:v 1 -q:v 2 <out>/ref-face.jpg
    ). Pass the absolute paths.
Write each prompt in English, concrete: the subject, the framing, the background, the light, the colors, the text on the image (3 words at most, written exactly in quotes, in the video's language), and the format. For a thumbnail: one subject, big readable text, strong contrast, a face with a clear emotion, nothing in the bottom right corner (YouTube puts the duration there). Every claim on the image comes from the video.
Show the prompts in a numbered list and wait for a yes (each image uses some of their Codex usage limit).
一张图片 = 一个 prompt。绝不要把多个创意塞进同一个 job。
只询问缺失的信息,并且集中在一个消息中:
  • 用途:缩略图(1280x720,16:9)、竖版封面(1080x1920,9:16)、方形帖子(1:1)、callout 或 B-roll 用的静帧(采用视频的画幅格式)。
  • 数量:默认 1 张;缩略图默认生成 3 个变体(每个变体采用不同创意,而不是将同一个创意重复三次)。
  • 创作者面部:缩略图中出现创作者本人时,需要 1 到 3 张清晰照片(也可以从一条 take 中截取一帧:
    ffmpeg -v error -y -ss <t> -i <take> -frames:v 1 -q:v 2 <out>/ref-face.jpg
    )。传入绝对路径。
每个 prompt 都用英文编写,并具体说明:主体、构图、背景、光线、颜色、图片上的文字(最多 3 个词,必须用引号原样写出,并使用视频的语言)以及格式。对于缩略图:只保留一个主体、使用大而清晰的文字、采用强烈对比度、面部表情鲜明,右下角不要放置任何内容(YouTube 会在那里显示时长)。图片上的每一项信息都必须有视频内容作为依据。
以编号列表展示 prompts,并等待用户明确同意(每张图片都会消耗一部分 Codex 使用额度)。

3. Generate

3. 生成

One job per prompt, at most 3 at a time, each in the background. Always end with
< /dev/null
(without it
codex exec
waits for input forever), and keep the last message in a file:
bash
mkdir -p <out>/logs
codex exec --skip-git-repo-check -s workspace-write -C "$PWD" \
  --output-last-message <out>/logs/<n>-<name>.txt \
  "Use your built-in image_gen tool to generate exactly one raster image for the prompt below. Do not edit any file. Do not ask questions. No SVG, no HTML, no placeholder.
Reference images (pass them to image_gen as referenced_image_paths): <absolute paths, or none>
When done, reply with exactly these two lines:
ASSET_NAME: <kebab-case-name>
IMAGE_PATH: <absolute path of the generated image>

Image prompt:
<the prompt>" \
  < /dev/null > <out>/logs/<n>-<name>.log 2>&1
A job takes about 1 to 3 minutes. When it ends, read its
.txt
, take
IMAGE_PATH
and copy the image:
bash
cp "<IMAGE_PATH>" <out>/<n>-<name>.png
No
IMAGE_PATH
in the answer: the newest file in
~/.codex/generated_images/
(
ls -t ~/.codex/generated_images/*/* | head -3
) created after the job started. Nothing new there: the job failed, show the end of its
.log
(often a usage limit, or
codex login
needed) and run that one again once.
每个 prompt 对应一个 job,最多同时运行 3 个,每个都在后台运行。命令末尾始终加上
< /dev/null
(否则
codex exec
会一直等待输入),并将最后一条消息保存在文件中:
bash
mkdir -p <out>/logs
codex exec --skip-git-repo-check -s workspace-write -C "$PWD" \
  --output-last-message <out>/logs/<n>-<name>.txt \
  "Use your built-in image_gen tool to generate exactly one raster image for the prompt below. Do not edit any file. Do not ask questions. No SVG, no HTML, no placeholder.
Reference images (pass them to image_gen as referenced_image_paths): <absolute paths, or none>
When done, reply with exactly these two lines:
ASSET_NAME: <kebab-case-name>
IMAGE_PATH: <absolute path of the generated image>

Image prompt:
<the prompt>" \
  < /dev/null > <out>/logs/<n>-<name>.log 2>&1
一个 job 大约需要 1 到 3 分钟。结束后,读取对应的
.txt
,取出
IMAGE_PATH
并复制图片:
bash
cp "<IMAGE_PATH>" <out>/<n>-<name>.png
如果回答中没有
IMAGE_PATH
:查找 job 启动后创建的
~/.codex/generated_images/
中最新文件(
ls -t ~/.codex/generated_images/*/* | head -3
)。如果那里没有新文件,说明 job 失败;展示其
.log
末尾内容(常见原因是达到使用限额,或需要运行
codex login
),然后仅重跑该 job 一次。

4. Check and hand over

4. 检查与交付

  • One image per prompt, and no two identical (
    shasum <out>/*.png
    ).
  • The size:
    sips -g pixelWidth -g pixelHeight <file>
    (macOS) or
    ffprobe -v error -show_entries stream=width,height -of csv=p=0 <file>
    . A thumbnail must be 16:9: crop or scale it to 1280x720 with ffmpeg (
    -vf "scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720"
    ), under 2 MB as JPG.
  • Look at each image: the text spelled right, the face like them, nothing odd (hands, extra letters). A wrong one: fix the prompt and run that one again.
Write
<out>/manifest.json
: one entry per image with
file
,
prompt
,
refs
,
date
. Show the images, then:
  • A thumbnail or cover:
    /video-publish
    uses
    <edit>/images/
    (they pick one, it is copied as
    <edit>/cover.jpg
    , the cover and the YouTube thumbnail).
  • A still for a video:
    /video-edit
    can place it as a callout image (copy it into
    video-agent/studio/public/
    ).
Delete
<out>/logs/
once everything is fine.
  • 每个 prompt 只对应一张图片,且任意两张都不得相同(
    shasum <out>/*.png
    )。
  • 尺寸:使用
    sips -g pixelWidth -g pixelHeight <file>
    (macOS)或
    ffprobe -v error -show_entries stream=width,height -of csv=p=0 <file>
    检查。缩略图必须为 16:9:使用 ffmpeg 将其裁剪或缩放至 1280x720(
    -vf "scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720"
    ),并保存为小于 2 MB 的 JPG。
  • 逐张检查图片:文字拼写正确、面部与创作者相似、没有异常内容(手指、多余字母等)。如果某张图片有误:修改 prompt,并只重跑该图片对应的 job。
编写
<out>/manifest.json
:每张图片一个条目,包含
file
、
prompt
、
refs
、
date
。展示图片,然后:
  • 缩略图或封面:
    /video-publish
    使用
    <edit>/images/
    (用户会挑选一张,挑选的图片会被复制为
    <edit>/cover.jpg
    ,用作封面和 YouTube 缩略图)。
  • 视频静帧:
    /video-edit
    可以将其作为 callout 图片放置(复制到
    video-agent/studio/public/
    )。
确认一切无误后,删除
<out>/logs/
。

Honest limits

实际限制

  • The image tool is OpenAI's, inside Codex: the result depends on it, and it changes. Text on the image can come out misspelled: always check it.
  • A face from reference photos looks close, rarely perfect. Real photos of them stay the safest for a thumbnail.
  • Each image counts against their ChatGPT plan's Codex limits; a limit reached means waiting or a bigger plan.
  • Only use photos of people who agreed, and no logos or characters they don't own.
  • image tool 是 Codex 内置的 OpenAI 工具:生成结果取决于该工具,而且输出会发生变化。图片中的文字可能会拼写错误,因此必须始终检查。
  • 基于参考照片生成的面孔通常比较接近,但很少完全一样。对于缩略图,使用创作者本人的真实照片仍是最稳妥的方案。
  • 每张图片都会计入用户 ChatGPT 套餐的 Codex 使用限额;达到限额后,只能等待或升级套餐。
  • 仅使用已获得同意的人物照片;不要使用创作者不拥有的 logo 或角色。