mcpField
B
baoyu-image-gen

baoyu-image-gen

github.com/smallnestクリエイティブ・メディア30942 回インストール15 週間前に更新
リポジトリ

baoyu-image-gen について

baoyu-image-gen は、AI SDK 経由で OpenAI と Google の画像モデルを使う画像生成スキルです。コマンドラインでの生成や編集に適し、参照画像や出力設定、プロバイダー選択に対応します。

主な機能

  1. 01OpenAI と Google の画像モデルを利用
  2. 02ファイルからプロンプトを読み込み
  3. 03縦横比、サイズ、画質を設定
  4. 04参照画像で編集やスタイル統合
  5. 05複数画像の生成を指定
  6. 06テキストまたは JSON で出力

活用シーン

  1. 01カバー画像やイラストの生成
  2. 02SNS 用の正方形画像の作成
  3. 03画像の背景やスタイルの変更
  4. 04プロンプトファイルから場面画像を生成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/smallnest/langgraphgo --skill baoyu-image-gen

インストール後、Claude Code で/baoyu-image-genを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

package-lock.json
package.json
scripts/
main.ts

詳細

画像生成(AI SDK)

AI SDK を使用した公式 API ベースの画像生成です。OpenAI(DALL-E、GPT Image)と Google(Imagen、Gemini マルチモーダル)に対応しています。

スクリプトディレクトリ

重要:すべてのスクリプトは、このスキルの scripts/ サブディレクトリにあります。

エージェントの実行手順:

  1. この SKILL.md ファイルのディレクトリパスを SKILL_DIR として特定します
  2. スクリプトのパス = ${SKILL_DIR}/scripts/<script-name>.ts
  3. このドキュメント内のすべての ${SKILL_DIR} を実際のパスに置き換えます

スクリプトのリファレンス:

スクリプト目的
scripts/main.ts画像生成の CLI エントリーポイント

クイックスタート

# Basic generation (auto-detect provider)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png

# With aspect ratio
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A landscape" --image landscape.png --ar 16:9

# High quality (2k)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality 2k

# Specific provider
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --provider openai

# From prompt files
npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png

# With reference images (Google multimodal only)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make blue" --image out.png --ref source.png

コマンド

基本的な画像生成
# Generate with prompt
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A sunset over mountains" --image sunset.png

# Shorthand
npx -y bun ${SKILL_DIR}/scripts/main.ts -p "A cute robot" --image robot.png
アスペクト比
# Common ratios: 1:1, 16:9, 9:16, 4:3, 3:4, 2.35:1
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A portrait" --image portrait.png --ar 3:4

# Or specify exact size
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Banner" --image banner.png --size 1792x1024
参照画像(Google マルチモーダル)
# Image editing with reference
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make it blue" --image blue.png --ref original.png

# Multiple references
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Combine these styles" --image out.png --ref a.png b.png
品質プリセット
# Normal quality (default)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality normal

# High quality (2k resolution)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality 2k
出力形式
# Plain output (prints saved path)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png

# JSON output
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --json

オプション

オプション説明
--prompt <text>, -pプロンプトのテキスト
--promptfiles <files...>ファイルからプロンプトを読み込みます(連結)
--image <path>出力画像のパス(必須)
--provider google|openaiプロバイダーを指定します(デフォルト:google)
--model <id>, -mモデル ID
--ar <ratio>アスペクト比(例:16:9、1:1、4:3)
--size <WxH>サイズ(例:1024x1024)
--quality normal|2k品質プリセット(デフォルト:normal)
--ref <files...>参照画像(Google マルチモーダルのみ)
--n <count>画像の枚数
--jsonJSON 出力
--help, -hヘルプを表示

環境変数

変数説明デフォルト
OPENAI_API_KEYOpenAI API キー-
GOOGLE_API_KEYGoogle API キー-
OPENAI_IMAGE_MODELOpenAI モデルgpt-image-1.5
GOOGLE_IMAGE_MODELGoogle モデルgemini-3-pro-image-preview
OPENAI_BASE_URLカスタム OpenAI エンドポイント-
GOOGLE_BASE_URLカスタム Google エンドポイント-

読み込みの優先順位:CLI 引数 > process.env > <cwd>/.baoyu-skills/.env > ~/.baoyu-skills/.env

プロバイダーとモデルの選択方法

自動選択
  1. --provider が指定されている場合 → 指定されたプロバイダーを使用します
  2. API キーが1つだけ使用可能な場合 → そのプロバイダーを使用します
  3. 両方使用可能な場合 → デフォルトで Google を使用します(マルチモーダル LLM のほうが汎用性に優れています)
モデルの種類に応じた API の選択
モデルのカテゴリAPI 関数モデルの例
Google マルチモーダルgenerateTextgemini-2.0-flash-exp-image-generation
Google Imagenexperimental_generateImageimagen-3.0-generate-002
OpenAIexperimental_generateImagegpt-image-1、dall-e-3
利用可能なモデル

Google:

  • gemini-3-pro-image-preview - デフォルト、マルチモーダル生成
  • gemini-2.0-flash-exp-image-generation - Gemini 2.0 Flash
  • imagen-3.0-generate-002 - Imagen 3

OpenAI:

  • gpt-image-1.5 - デフォルト、GPT Image 1.5
  • gpt-image-1 - GPT Image 1
  • dall-e-3 - DALL-E 3

品質プリセット

プリセットOpenAIGoogle用途
normal1024x1024デフォルトカバー、イラスト
2k2048x2048プロンプトに「2048px」インフォグラフィック、スライド

アスペクト比の処理

  • マルチモーダル LLM:プロンプトに埋め込まれます(例:"... aspect ratio 16:9")
  • 画像専用モデル:aspectRatio または size パラメーターを使用します
  • 一般的な比率:1:1、16:9、9:16、4:3、3:4、2.35:1

例

カバー画像を生成する
npx -y bun ${SKILL_DIR}/scripts/main.ts \
  --prompt "A minimalist tech illustration with blue gradients" \
  --image cover.png --ar 2.35:1 --quality 2k
ソーシャルメディアの投稿を生成する
npx -y bun ${SKILL_DIR}/scripts/main.ts \
  --prompt "Instagram post about coffee" \
  --image post.png --ar 1:1
参照画像を使って画像を編集する
npx -y bun ${SKILL_DIR}/scripts/main.ts \
  --prompt "Change the background to sunset" \
  --image edited.png --ref original.png --provider google
プロンプトファイルから一括生成する
# Create prompt file with detailed instructions
npx -y bun ${SKILL_DIR}/scripts/main.ts \
  --promptfiles style-guide.md scene-description.md \
  --image scene.png

エラー処理

  • API キーがない場合:設定手順を含む明確なエラーが表示されます
  • 生成に失敗した場合:自動で1回再試行し、その後エラーになります
  • アスペクト比が無効な場合:警告を表示し、デフォルト値で続行します
  • 画像専用モデルで参照画像を使用した場合:警告を表示し、参照画像を無視します

拡張機能のサポート

EXTEND.md によるカスタム設定。

確認するパス(優先順位順):

  1. .baoyu-skills/baoyu-image-gen/EXTEND.md(プロジェクト)
  2. ~/.baoyu-skills/baoyu-image-gen/EXTEND.md(ユーザー)

見つかった場合は、ワークフローの前に読み込みます。拡張内容はデフォルト設定より優先されます。

コメント