跳到正文
cccskills
免费在 GitHub 公开

gemini-imagegen

Generate images from text prompts or edit them with Google Gemini. The skill also covers combining reference images and keeping a person’s appearance consistent across a set, with guidance for model choice, image ratios, and prompt details.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Generate and edit images using Google Gemini's native image generation models (Nano Banana / Nano Banana Pro). Supports text-to-image, image editing with reference images, multi-image composition, and character consistency. Use when the user asks to generate images via Gemini, create AI illustrations, edit photos with Gemini, or needs high-quality image generation with the Google API. Requires GEMINI_API_KEY. Triggers: "generate image with gemini", "nano banana", "gemini image", "create illustration", "AI generate picture", "text to image".

dp-archive/archive星标 1,107(GitHub 1,107 + cccskills 0)
集成工具Gemini

实测评分 未实测

查看安装方法

适用场景

  • Creating an illustration from a text prompt
  • Editing a photo with a reference image
  • Combining several reference images
  • Keeping a character consistent across images

包含的文件(1)

  • SKILL.md5.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Gemini Image Generation

Generate and edit images via Google Gemini's native multimodal image generation.

Model Selection

Model IDCodenameBest forMax resolution
gemini-2.5-flash-imageNano BananaFast drafts, high-volume, low-latency1K
gemini-3-pro-image-previewNano Banana ProStudio-quality, text rendering, complex prompts4K

Default: gemini-3-pro-image-preview (Pro) unless speed/cost is a concern.

Setup

# Install (once)
# pip install google-genai

from google import genai
import os, base64

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])

If GEMINI_API_KEY is missing, instruct the user to set it as an environment variable. Never ask the user to paste the key in chat.

Text-to-Image

from google import genai
from google.genai import types
import os

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents="A photorealistic cat on a rainbow sofa",
    config=types.GenerateContentConfig(
        response_modalities=["TEXT", "IMAGE"],
    ),
)

# Extract and save
for part in response.candidates[0].content.parts:
    if part.inline_data is not None:
        with open("output.png", "wb") as f:
            f.write(part.inline_data.data)
        break

Aspect Ratio

Set via image_config:

config=types.GenerateContentConfig(
    response_modalities=["TEXT", "IMAGE"],
    image_config=types.ImageConfig(
        aspect_ratio="16:9",  # for slides / widescreen
    ),
)

Supported ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9

Common choices:

  • Slides / presentations → 16:9
  • Social media / portraits → 9:16 or 4:5
  • Square thumbnails → 1:1

Image Editing (with reference image)

from google.genai import types
from pathlib import Path
import base64

ref_bytes = Path("input.jpg").read_bytes()

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents=[
        types.Part(inline_data=types.Blob(mime_type="image/jpeg", data=base64.b64encode(ref_bytes).decode())),
        types.Part(text="Remove the background and replace with a sunset gradient"),
    ],
    config=types.GenerateContentConfig(
        response_modalities=["TEXT", "IMAGE"],
    ),
)

Pro supports up to 14 reference images for multi-image composition and up to 5 human reference images for character/identity consistency.

Batch Generation (for slides)

When generating multiple images (e.g. one per slide), loop sequentially and save with numbered filenames:

import os, time
from google import genai
from google.genai import types

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])

prompts = [...]  # list of prompt strings

for i, prompt in enumerate(prompts, 1):
    response = client.models.generate_content(
        model="gemini-3-pro-image-preview",
        contents=prompt,
        config=types.GenerateContentConfig(
            response_modalities=["TEXT", "IMAGE"],
            image_config=types.ImageConfig(aspect_ratio="16:9"),
        ),
    )
    for part in response.candidates[0].content.parts:
        if part.inline_data is not None:
            with open(f"slide_{i}.png", "wb") as f:
                f.write(part.inline_data.data)
            break
    time.sleep(1)  # rate limit courtesy

Error Handling

  • Safety filter block: The model may refuse prompts it deems unsafe. Adjust the prompt to be less ambiguous (remove violent/adult/medical imagery language) and retry.
  • Empty response: If response.candidates is empty or has no image parts, the prompt may be too vague. Add concrete scene details and retry.
  • Rate limit (429): Back off with exponential delay. Default: time.sleep(2 ** attempt).
  • Timeout: Set a reasonable timeout; Pro model may take 10–30s for complex prompts.

Prompt Best Practices

  • Structure: scene → subject → style → composition → constraints
  • Always specify art style: "flat vector illustration", "watercolor painting", "3D render", "photorealistic photograph"
  • Include lighting and mood: "soft diffused lighting", "dramatic rim light", "golden hour"
  • For text in images: quote exact text, specify font style and placement
  • For slide illustrations: add "negative space on [side]" to leave room for text overlay
  • Use English prompts even for non-English content (better generation quality)
  • Keep prompts under 500 words; be specific but not verbose

Style Consistency for Multi-Image Sets

When generating a series (e.g. slide deck), prepend a style prefix to every prompt:

Style prefix: "flat vector illustration, soft pastel color palette, clean lines, minimal detail, 16:9 widescreen"

Slide 1 prompt: "{style_prefix}, a wide establishing shot of a modern office building at sunrise"
Slide 2 prompt: "{style_prefix}, a close-up of hands typing on a laptop keyboard"

This ensures visual coherence across all generated images.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Review text for patterns associated with AI-generated writing, including vocabulary, structure, formatting, citations, and model-specific artifacts. The skill combines multiple signals, weighs context and mitigating evidence, and presents a cautious assessment with confidence and caveats.

中文简介正在准备中。当前显示英语简介。

  • Review an essay for multiple AI-writing signals
  • Explain which text patterns may suggest AI authorship
  • Assess a draft while accounting for false-positive risks
dp-archive/archive11072026年3月4日 更新

Extract audio from videos or download audio from supported websites with yt-dlp, then save it as MP3, M4A, FLAC, WAV, or OPUS. The workflow can embed track metadata and cover art, and process playlists or podcast episodes in batches.

中文简介正在准备中。当前显示英语简介。

  • Save a video's audio as MP3 or FLAC
  • Download podcast episodes as audio files
  • Convert a playlist into numbered audio tracks
dp-archive/archive11072026年3月4日 更新

biopython

免费

Use Biopython to process DNA, RNA, and protein sequences, read and convert common biology file formats, run alignments or BLAST searches, access NCBI records, and work with protein structures and phylogenetic trees in Python.

中文简介正在准备中。当前显示英语简介。

  • Reading and converting FASTA, GenBank, or PDB files
  • Calculating sequence statistics or translating DNA
  • Searching NCBI and PubMed records in batches
dp-archive/archive11072026年3月4日 更新

Turn a project description into a coordinated visual identity package. Define logo variants, color palettes, and typography, then create layouts for business cards and social media covers along with a brand specification document for consistent use.

中文简介正在准备中。当前显示英语简介。

  • Creating a logo system and brand kit
  • Choosing colors and typography for a new project
  • Designing a business card and social media cover
dp-archive/archive11072026年3月4日 更新

Create original posters and static artwork by first defining a visual direction for color, shape, space, and typography. Receive a Markdown design philosophy alongside a PNG or PDF artwork that communicates primarily through visuals.

中文简介正在准备中。当前显示英语简介。

  • Create an original poster
  • Express a theme through abstract artwork
  • Develop a visual direction and finished artwork
dp-archive/archive11072026年3月4日 更新

Turn a codebase into Mermaid diagrams such as architecture, ER, sequence, class, and flow diagrams. It analyzes relevant files, writes diagram source, renders SVG and PNG images, and checks the rendered result for readability and correctness.

中文简介正在准备中。当前显示英语简介。

  • Visualize a codebase architecture
  • Create an ER diagram from database models
  • Show an API flow as a sequence diagram
dp-archive/archive11072026年3月4日 更新

查看 dp-archive 的全部技能

报告此技能的问题