Skip to content

新章案: ChatGPT Images 2.0(gpt-image-2)× PIL で画像編集 #48

@watanabe-kohei-jp

Description

@watanabe-kohei-jp

背景

画像の生成と編集をコードで回せると、資料作成・OGP 画像・サムネ量産などが自動化できる。2026-04-21 に OpenAI が公開した ChatGPT Images 2.0(API モデル ID: gpt-image-2 は、テキスト描画・多言語・推論ベースの生成に強く、API(v1/images/generations / v1/images/edits)と Codex から利用できる。

ただし生成 AI は「最後の 1px の調整」(正確なサイズ・余白・文字合成・フォーマット変換)は苦手。そこを PIL(Pillow) で補う。「AI で生成 → PIL で仕上げ」という役割分担を、Claude Code に書かせて回すのがこの章のテーマ。

目的

Claude Code に「gpt-image-2 で生成 → PIL でリサイズ・合成・文字入れ・書き出し」というワークフローを書かせ、受講者が自分の用途(OGP・サムネ等)で再現できるようにする。

スコープ

in scope

  • なぜ画像処理をコードで回すのか(再現性・量産・バージョン管理)
  • 生成(gpt-image-2)と編集(PIL)の役割分担
  • gpt-image-2 API 呼び出しの概要(generations / edits、サイズ・出力)
  • PIL の基本操作(open / resize / crop / paste / ImageDraw で文字入れ / save)
  • Claude Code に一連のスクリプトを書かせ・直させる流れ

out of scope

  • gpt-image-2 の料金・レート詳細(古くなる前提。出典付きで概略のみ)
  • 画像処理の高度な理論(フィルタ実装の内部 等)

設計方針(叩き台)

  • 既存講義と同じ HTML スライド構成
  • 番号は 07-*。slug 案: 07-image-editing
  • API キー等の秘匿情報はスライドに載せない(環境変数前提)
  • 数字(料金・解像度)は「as-of 2026/06」と出典を併記し、更新可能な形に

受け入れ条件

  • 07-image-editing/index.html を追加(10〜13 枚程度)
  • <title><meta name="description"> を記入(listing 自動同期の真実源)
  • <section>data-label="<章> · <タイトル> — <サブ>" を付与
  • スクリプト読み込み順を遵守(theme.css → deck-stage.js → progress-strip.js → page-number.js → ai-focus.js)
  • python3 scripts/sync_listings.py --write で listing を同期
  • CI green(sync-listings-check / prompt-injection-check / pages-deploy build)

関連

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions