Bilder mit Gemini generieren (auch als Nano Banana bezeichnet)

Gemini kann Bilder im Rahmen von Unterhaltungen generieren und verarbeiten. Sie können Gemini mit Text, Bildern oder einer Kombination aus beidem auffordern, um Bilder mit beispielloser Kontrolle zu erstellen, zu bearbeiten und zu optimieren:

  • Text-to-Image::Generieren Sie hochwertige Bilder aus einfachen oder komplexen Textbeschreibungen.
  • Bild + Text-zu-Bild (Bearbeitung): Sie stellen ein Bild bereit und verwenden Text-Prompts, um Elemente hinzuzufügen, zu entfernen oder zu ändern, den Stil zu ändern oder die Farbkorrektur anzupassen.
  • Mehrere Bilder zu einem Bild (Komposition und Stilübertragung): Verwenden Sie mehrere Eingabebilder, um eine neue Szene zu erstellen oder den Stil eines Bildes auf ein anderes zu übertragen.
  • Iterative Optimierung:Sie können sich mit dem KI-Modell unterhalten, um Ihr Bild schrittweise zu optimieren. Dabei werden in mehreren Schritten kleine Anpassungen vorgenommen, bis das Bild perfekt ist.
  • Textwiedergabe in hoher Qualität:Bilder mit gut lesbarem und gut platziertem Text werden präzise generiert. Das ist ideal für Logos, Diagramme und Poster.

Alle generierten Bilder enthalten ein SynthID-Wasserzeichen.

Bildgenerierung (Text-zu-Bild)

Der folgende Code zeigt, wie ein Bild auf Grundlage eines beschreibenden Prompts generiert wird.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

prompt = (
    "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"
)

response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[prompt],
)

for part in response.candidates[0].content.parts:
    if part.text is not None:
        print(part.text)
    elif part.inline_data is not None:
        image = Image.open(BytesIO(part.inline_data.data))
        image.save("generated_image.png")

JavaScript

import { GoogleGenAI, Modality } from "@google/genai";
import * as fs from "node:fs";

async function main() {

  const ai = new GoogleGenAI({});

  const prompt =
    "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme";

  const response = await ai.models.generateContent({
    model: "gemini-2.5-flash-image-preview",
    contents: prompt,
  });
  for (const part of response.candidates[0].content.parts) {
    if (part.text) {
      console.log(part.text);
    } else if (part.inlineData) {
      const imageData = part.inlineData.data;
      const buffer = Buffer.from(imageData, "base64");
      fs.writeFileSync("gemini-native-image.png", buffer);
      console.log("Image saved as gemini-native-image.png");
    }
  }
}

main();

Ok

package main

import (
  "context"
  "fmt"
  "os"
  "google.golang.org/genai"
)

func main() {

  ctx := context.Background()
  client, err := genai.NewClient(ctx, nil)
  if err != nil {
      log.Fatal(err)
  }

  result, _ := client.Models.GenerateContent(
      ctx,
      "gemini-2.5-flash-image-preview",
      genai.Text("Create a picture of a nano banana dish in a " +
                 " fancy restaurant with a Gemini theme"),
  )

  for _, part := range result.Candidates[0].Content.Parts {
      if part.Text != "" {
          fmt.Println(part.Text)
      } else if part.InlineData != nil {
          imageBytes := part.InlineData.Data
          outputFilename := "gemini_generated_image.png"
          _ = os.WriteFile(outputFilename, imageBytes, 0644)
      }
  }
}

REST

curl -s -X POST
  "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
      ]
    }]
  }' \
  | grep -o '"data": "[^"]*"' \
  | cut -d'"' -f4 \
  | base64 --decode > gemini-native-image.png
KI-generiertes Bild eines Gerichts mit Nanobananen
KI-generiertes Bild eines Gerichts mit Nanobananen in einem Restaurant mit Gemini-Thema

Bildbearbeitung (Text-und-Bild-zu-Bild)

Zur Erinnerung: Sie müssen die erforderlichen Rechte an den Bildern haben, die Sie hochladen möchten. Erstellen Sie keine Inhalte, durch die die Rechte anderer verletzt werden, einschließlich Videos oder Bilder, die jemanden täuschen, belästigen oder schädigen können. Ihre Verwendung dieses auf generativer KI basierenden Dienstes unterliegt unserer Richtlinie zur unzulässigen Nutzung.

Im folgenden Beispiel wird das Hochladen von base64-codierten Bildern veranschaulicht. Informationen zu mehreren Bildern, größeren Nutzlasten und unterstützten MIME-Typen finden Sie auf der Seite Bildanalyse.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

prompt = (
    "Create a picture of my cat eating a nano-banana in a "
    "fancy restaurant under the Gemini constellation",
)

image = Image.open("/path/to/cat_image.png")

response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[prompt, image],
)

for part in response.candidates[0].content.parts:
    if part.text is not None:
        print(part.text)
    elif part.inline_data is not None:
        image = Image.open(BytesIO(part.inline_data.data))
        image.save("generated_image.png")

JavaScript

import { GoogleGenAI, Modality } from "@google/genai";
import * as fs from "node:fs";

async function main() {

  const ai = new GoogleGenAI({});

  const imagePath = "path/to/cat_image.png";
  const imageData = fs.readFileSync(imagePath);
  const base64Image = imageData.toString("base64");

  const prompt = [
    { text: "Create a picture of my cat eating a nano-banana in a" +
            "fancy restaurant under the Gemini constellation" },
    {
      inlineData: {
        mimeType: "image/png",
        data: base64Image,
      },
    },
  ];

  const response = await ai.models.generateContent({
    model: "gemini-2.5-flash-image-preview",
    contents: prompt,
  });
  for (const part of response.candidates[0].content.parts) {
    if (part.text) {
      console.log(part.text);
    } else if (part.inlineData) {
      const imageData = part.inlineData.data;
      const buffer = Buffer.from(imageData, "base64");
      fs.writeFileSync("gemini-native-image.png", buffer);
      console.log("Image saved as gemini-native-image.png");
    }
  }
}

main();

Ok

package main

import (
 "context"
 "fmt"
 "os"
 "google.golang.org/genai"
)

func main() {

 ctx := context.Background()
 client, err := genai.NewClient(ctx, nil)
 if err != nil {
     log.Fatal(err)
 }

 imagePath := "/path/to/cat_image.png"
 imgData, _ := os.ReadFile(imagePath)

 parts := []*genai.Part{
   genai.NewPartFromText("Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation"),
   &genai.Part{
     InlineData: &genai.Blob{
       MIMEType: "image/png",
       Data:     imgData,
     },
   },
 }

 contents := []*genai.Content{
   genai.NewContentFromParts(parts, genai.RoleUser),
 }

 result, _ := client.Models.GenerateContent(
     ctx,
     "gemini-2.5-flash-image-preview",
     contents,
 )

 for _, part := range result.Candidates[0].Content.Parts {
     if part.Text != "" {
         fmt.Println(part.Text)
     } else if part.InlineData != nil {
         imageBytes := part.InlineData.Data
         outputFilename := "gemini_generated_image.png"
         _ = os.WriteFile(outputFilename, imageBytes, 0644)
     }
 }
}

REST

IMG_PATH=/path/to/cat_image.jpeg

if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
  B64FLAGS="--input"
else
  B64FLAGS="-w0"
fi

IMG_BASE64=$(base64 "$B64FLAGS" "$IMG_PATH" 2>&1)

curl -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent" \
    -H "x-goog-api-key: $GEMINI_API_KEY" \
    -H 'Content-Type: application/json' \
    -d "{
      \"contents\": [{
        \"parts\":[
            {\"text\": \"'Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation\"},
            {
              \"inline_data\": {
                \"mime_type\":\"image/jpeg\",
                \"data\": \"$IMG_BASE64\"
              }
            }
        ]
      }]
    }"  \
  | grep -o '"data": "[^"]*"' \
  | cut -d'"' -f4 \
  | base64 --decode > gemini-edited-image.png
KI-generiertes Bild einer Katze, die eine Anano-Banane isst
KI-generiertes Bild einer Katze, die eine Nanobananen isst

Andere Modi zur Bildgenerierung

Gemini unterstützt je nach Prompt-Struktur und Kontext auch andere Modi für die Bildinteraktion:

  • Text zu Bild(ern) und Text (verschachtelt): Es werden Bilder mit zugehörigem Text ausgegeben.
    • Beispiel-Prompt: „Erstelle ein illustriertes Rezept für eine Paella.“
  • Bild(er) und Text zu Bild(ern) und Text (verschachtelt): Verwendet Eingabebilder und ‑text, um neue zugehörige Bilder und Texte zu erstellen.
    • Beispielprompt: (Mit einem Bild eines möblierten Zimmers) „Welche anderen Farben für Sofas würden in meinem Raum passen? Kannst du das Bild aktualisieren?“
  • Multi-Turn-Bildbearbeitung (Chat): Sie können Bilder im Chat generieren und bearbeiten lassen.
    • Beispiel-Prompts: [Lade ein Bild eines blauen Autos hoch.] , „Mach aus diesem Auto ein Cabriolet.“ „Ändere die Farbe jetzt in Gelb.“

Anleitung und Strategien für Prompts

Die Bildgenerierung mit Gemini 2.5 Flash basiert auf einem grundlegenden Prinzip:

Beschreiben Sie die Szene, anstatt nur Keywords aufzulisten. Die Stärke des Modells liegt in seinem tiefen Sprachverständnis. Ein narrativer, beschreibender Absatz führt fast immer zu einem besseren, kohärenteren Bild als eine Liste mit unzusammenhängenden Wörtern.

Prompts zum Generieren von Bildern

Die folgenden Strategien helfen Ihnen dabei, effektive Prompts zu erstellen, mit denen Sie genau die Bilder generieren können, die Sie suchen.

1. Fotorealistische Szenen

Verwenden Sie für realistische Bilder fotografische Begriffe. Erwähnen Sie Kamerawinkel, Objektivtypen, Beleuchtung und feine Details, um das Modell in Richtung eines fotorealistischen Ergebnisses zu lenken.

Vorlage

A photorealistic [shot type] of [subject], [action or expression], set in
[environment]. The scene is illuminated by [lighting description], creating
a [mood] atmosphere. Captured with a [camera/lens details], emphasizing
[key textures and details]. The image should be in a [aspect ratio] format.

Prompt

A photorealistic close-up portrait of an elderly Japanese ceramicist with
deep, sun-etched wrinkles and a warm, knowing smile. He is carefully
inspecting a freshly glazed tea bowl. The setting is his rustic,
sun-drenched workshop. The scene is illuminated by soft, golden hour light
streaming through a window, highlighting the fine texture of the clay.
Captured with an 85mm portrait lens, resulting in a soft, blurred background
(bokeh). The overall mood is serene and masterful. Vertical portrait
orientation.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents="A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful.",
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('photorealistic_example.png')
    image.show()
Ein fotorealistisches Porträt einer älteren japanischen Keramikerin in Nahaufnahme…
Ein fotorealistisches Nahaufnahmeporträt eines älteren japanischen Keramikers…

2. Stilisierte Illustrationen und Sticker

Wenn Sie Sticker, Symbole oder Assets erstellen möchten, geben Sie den Stil genau an und fordern Sie einen transparenten Hintergrund an.

Vorlage

A [style] sticker of a [subject], featuring [key characteristics] and a
[color palette]. The design should have [line style] and [shading style].
The background must be transparent.

Prompt

A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's
munching on a green bamboo leaf. The design features bold, clean outlines,
simple cel-shading, and a vibrant color palette. The background must be white.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents="A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's munching on a green bamboo leaf. The design features bold, clean outlines, simple cel-shading, and a vibrant color palette. The background must be white.",
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('red_panda_sticker.png')
    image.show()
Ein Sticker im Kawaii-Stil mit einem fröhlichen roten…
Ein Sticker im Kawaii-Stil mit einem fröhlichen roten Panda...

3. Genaue Darstellung von Text in Bildern

Gemini ist hervorragend im Rendern von Text. Beschreiben Sie den Text, den Schriftstil und das Gesamtdesign so genau wie möglich.

Vorlage

Create a [image type] for [brand/concept] with the text "[text to render]"
in a [font style]. The design should be [style description], with a
[color scheme].

Prompt

Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'.
The text should be in a clean, bold, sans-serif font. The design should
feature a simple, stylized icon of a a coffee bean seamlessly integrated
with the text. The color scheme is black and white.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents="Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The design should feature a simple, stylized icon of a a coffee bean seamlessly integrated with the text. The color scheme is black and white.",
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('logo_example.png')
    image.show()
Erstelle ein modernes, minimalistisches Logo für ein Café namens „The Daily Grind“ …
Erstelle ein modernes, minimalistisches Logo für ein Café namens „The Daily Grind“ …

4. Produkt-Mockups und kommerzielle Fotografie

Ideal für die Erstellung von sauberen, professionellen Produktaufnahmen für E-Commerce, Werbung oder Branding.

Vorlage

A high-resolution, studio-lit product photograph of a [product description]
on a [background surface/description]. The lighting is a [lighting setup,
e.g., three-point softbox setup] to [lighting purpose]. The camera angle is
a [angle type] to showcase [specific feature]. Ultra-realistic, with sharp
focus on [key detail]. [Aspect ratio].

Prompt

A high-resolution, studio-lit product photograph of a minimalist ceramic
coffee mug in matte black, presented on a polished concrete surface. The
lighting is a three-point softbox setup designed to create soft, diffused
highlights and eliminate harsh shadows. The camera angle is a slightly
elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with
sharp focus on the steam rising from the coffee. Square image.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents="A high-resolution, studio-lit product photograph of a minimalist ceramic coffee mug in matte black, presented on a polished concrete surface. The lighting is a three-point softbox setup designed to create soft, diffused highlights and eliminate harsh shadows. The camera angle is a slightly elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with sharp focus on the steam rising from the coffee. Square image.",
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('product_mockup.png')
    image.show()
Ein hochauflösendes, im Studio aufgenommenes Produktfoto einer minimalistischen Kaffeetasse aus Keramik…
Ein hochauflösendes, im Studio aufgenommenes Produktfoto einer minimalistischen Keramiktasse…

5. Minimalistisches Design und Negativraum

Hervorragend geeignet für Hintergründe für Websites, Präsentationen oder Marketingmaterialien, auf denen Text eingeblendet werden soll.

Vorlage

A minimalist composition featuring a single [subject] positioned in the
[bottom-right/top-left/etc.] of the frame. The background is a vast, empty
[color] canvas, creating significant negative space. Soft, subtle lighting.
[Aspect ratio].

Prompt

A minimalist composition featuring a single, delicate red maple leaf
positioned in the bottom-right of the frame. The background is a vast, empty
off-white canvas, creating significant negative space for text. Soft,
diffused lighting from the top left. Square image.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents="A minimalist composition featuring a single, delicate red maple leaf positioned in the bottom-right of the frame. The background is a vast, empty off-white canvas, creating significant negative space for text. Soft, diffused lighting from the top left. Square image.",
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('minimalist_design.png')
    image.show()
Eine minimalistische Komposition mit einem einzelnen, zarten roten Ahornblatt…
Eine minimalistische Komposition mit einem einzelnen, zarten roten Ahornblatt…

6. Sequenzielle Kunst (Comic-Panel / Storyboard)

Baut auf der Konsistenz der Charaktere und der Szenenbeschreibung auf, um Panels für das visuelle Storytelling zu erstellen.

Vorlage

A single comic book panel in a [art style] style. In the foreground,
[character description and action]. In the background, [setting details].
The panel has a [dialogue/caption box] with the text "[Text]". The lighting
creates a [mood] mood. [Aspect ratio].

Prompt

A single comic book panel in a gritty, noir art style with high-contrast
black and white inks. In the foreground, a detective in a trench coat stands
under a flickering streetlamp, rain soaking his shoulders. In the
background, the neon sign of a desolate bar reflects in a puddle. A caption
box at the top reads "The city was a tough place to keep secrets." The
lighting is harsh, creating a dramatic, somber mood. Landscape.

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents="A single comic book panel in a gritty, noir art style with high-contrast black and white inks. In the foreground, a detective in a trench coat stands under a flickering streetlamp, rain soaking his shoulders. In the background, the neon sign of a desolate bar reflects in a puddle. A caption box at the top reads \"The city was a tough place to keep secrets.\" The lighting is harsh, creating a dramatic, somber mood. Landscape.",
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('comic_panel.png')
    image.show()
Ein einzelnes Comic-Panel in einem düsteren Noir-Stil…
Ein einzelnes Comic-Panel in einem düsteren Noir-Stil...

Prompts zum Bearbeiten von Bildern

In diesen Beispielen wird gezeigt, wie Sie Bilder zusammen mit Ihren Text-Prompts für die Bearbeitung, Komposition und Stilübertragung bereitstellen.

1. Elemente hinzufügen und entfernen

Stellen Sie ein Bild bereit und beschreiben Sie Ihre Änderung. Das Modell entspricht dem Stil, der Beleuchtung und der Perspektive des Originalbilds.

Vorlage

Using the provided image of [subject], please [add/remove/modify] [element]
to/from the scene. Ensure the change is [description of how the change should
integrate].

Prompt

"Using the provided image of my cat, please add a small, knitted wizard hat
on its head. Make it look like it's sitting comfortably and matches the soft
lighting of the photo."

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Base image prompt: "A photorealistic picture of a fluffy ginger cat sitting on a wooden floor, looking directly at the camera. Soft, natural light from a window."
image_input = Image.open('/path/to/your/cat_photo.png')
text_input = """Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and not falling off."""

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[text_input, image_input],
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('cat_with_hat.png')
    image.show()

Eingabe

Ausgabe

Ein fotorealistisches Bild einer flauschigen, rotbraunen Katze.
Ein fotorealistisches Bild einer flauschigen roten Katze...
Füge dem bereitgestellten Bild meiner Katze einen kleinen, gestrickten Zaubererhut hinzu…
Füge dem bereitgestellten Bild meiner Katze einen kleinen, gestrickten Zaubererhut hinzu…

2. Übermalen (semantische Maskierung)

Definieren Sie im Dialog eine „Maske“, um einen bestimmten Teil eines Bildes zu bearbeiten, während der Rest unverändert bleibt.

Vorlage

Using the provided image, change only the [specific element] to [new
element/description]. Keep everything else in the image exactly the same,
preserving the original style, lighting, and composition.

Prompt

"Using the provided image of a living room, change only the blue sofa to be
a vintage, brown leather chesterfield sofa. Keep the rest of the room,
including the pillows on the sofa and the lighting, unchanged."

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Base image prompt: "A wide shot of a modern, well-lit living room with a prominent blue sofa in the center. A coffee table is in front of it and a large window is in the background."
living_room_image = Image.open('/path/to/your/living_room.png')
text_input = """Using the provided image of a living room, change only the blue sofa to be a vintage, brown leather chesterfield sofa. Keep the rest of the room, including the pillows on the sofa and the lighting, unchanged."""

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[living_room_image, text_input],
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('living_room_edited.png')
    image.show()

Eingabe

Ausgabe

Eine Weitwinkelaufnahme eines modernen, gut beleuchteten Wohnzimmers…
Eine Weitwinkelaufnahme eines modernen, gut beleuchteten Wohnzimmers…
Ändere auf dem bereitgestellten Bild eines Wohnzimmers nur das blaue Sofa in ein braunes Chesterfield-Sofa aus Vintage-Leder.
Ändere auf dem bereitgestellten Bild eines Wohnzimmers nur das blaue Sofa in ein braunes Chesterfield-Sofa aus Leder im Vintage-Stil…

3. Stilübertragung

Stellen Sie ein Bild zur Verfügung und bitten Sie das Modell, den Inhalt in einem anderen künstlerischen Stil neu zu erstellen.

Vorlage

Transform the provided photograph of [subject] into the artistic style of [artist/art style]. Preserve the original composition but render it with [description of stylistic elements].

Prompt

"Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Base image prompt: "A photorealistic, high-resolution photograph of a busy city street in New York at night, with bright neon signs, yellow taxis, and tall skyscrapers."
city_image = Image.open('/path/to/your/city.png')
text_input = """Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."""

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[city_image, text_input],
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('city_style_transfer.png')
    image.show()

Eingabe

Ausgabe

Ein fotorealistisches Foto einer belebten Straße in hoher Auflösung…
Ein fotorealistisches, hochauflösendes Foto einer belebten Straße in einer Großstadt...
Verwandle das bereitgestellte Foto einer modernen Stadtstraße bei Nacht…
Transformiere das bereitgestellte Foto einer modernen Stadtstraße bei Nacht...

4. Erweiterte Komposition: Mehrere Bilder kombinieren

Mehrere Bilder als Kontext für die Erstellung einer neuen, zusammengesetzten Szene bereitstellen Das ist ideal für Produkt-Mockups oder kreative Collagen.

Vorlage

Create a new image by combining the elements from the provided images. Take
the [element from image 1] and place it with/on the [element from image 2].
The final image should be a [description of the final scene].

Prompt

"Create a professional e-commerce fashion photo. Take the blue floral dress
from the first image and let the woman from the second image wear it.
Generate a realistic, full-body shot of the woman wearing the dress, with
the lighting and shadows adjusted to match the outdoor environment."

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Base image prompts:
# 1. Dress: "A professionally shot photo of a blue floral summer dress on a plain white background, ghost mannequin style."
# 2. Model: "Full-body shot of a woman with her hair in a bun, smiling, standing against a neutral grey studio background."
dress_image = Image.open('/path/to/your/dress.png')
model_image = Image.open('/path/to/your/model.png')

text_input = """Create a professional e-commerce fashion photo. Take the blue floral dress from the first image and let the woman from the second image wear it. Generate a realistic, full-body shot of the woman wearing the dress, with the lighting and shadows adjusted to match the outdoor environment."""

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[dress_image, model_image, text_input],
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('fashion_ecommerce_shot.png')
    image.show()

Eingabe 1

Eingabe 2

Ausgabe

Ein professionell aufgenommenes Foto eines blauen Sommerkleids mit Blumenmuster…
Ein professionell aufgenommenes Foto eines blauen Sommerkleids mit Blumenmuster…
Ganzkörperaufnahme einer Frau mit einem Dutt…
Ganzkörperaufnahme einer Frau mit einem Dutt…
Erstelle ein professionelles E‑Commerce-Modefoto…
Erstelle ein professionelles E‑Commerce-Modefoto…

5. High-Fidelity-Detailerhaltung

Damit wichtige Details wie ein Gesicht oder ein Logo bei der Bearbeitung erhalten bleiben, beschreiben Sie sie zusammen mit Ihrem Bearbeitungswunsch so detailliert wie möglich.

Vorlage

Using the provided images, place [element from image 2] onto [element from
image 1]. Ensure that the features of [element from image 1] remain
completely unchanged. The added element should [description of how the
element should integrate].

Prompt

"Take the first image of the woman with brown hair, blue eyes, and a neutral
expression. Add the logo from the second image onto her black t-shirt.
Ensure the woman's face and features remain completely unchanged. The logo
should look like it's naturally printed on the fabric, following the folds
of the shirt."

Python

from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO

client = genai.Client()

# Base image prompts:
# 1. Woman: "A professional headshot of a woman with brown hair and blue eyes, wearing a plain black t-shirt, against a neutral studio background."
# 2. Logo: "A simple, modern logo with the letters 'G' and 'A' in a white circle."
woman_image = Image.open('/path/to/your/woman.png')
logo_image = Image.open('/path/to/your/logo.png')
text_input = """Take the first image of the woman with brown hair, blue eyes, and a neutral expression. Add the logo from the second image onto her black t-shirt. Ensure the woman's face and features remain completely unchanged. The logo should look like it's naturally printed on the fabric, following the folds of the shirt."""

# Generate an image from a text prompt
response = client.models.generate_content(
    model="gemini-2.5-flash-image-preview",
    contents=[woman_image, logo_image, text_input],
)

image_parts = [
    part.inline_data.data
    for part in response.candidates[0].content.parts
    if part.inline_data
]

if image_parts:
    image = Image.open(BytesIO(image_parts[0]))
    image.save('woman_with_logo.png')
    image.show()

Eingabe 1

Eingabe 2

Ausgabe

Ein professionelles Portrait einer Frau mit braunen Haaren und blauen Augen…
Ein professionelles Portrait einer Frau mit braunen Haaren und blauen Augen...
Ein einfaches, modernes Logo mit den Buchstaben „G“ und „A“...
Ein einfaches, modernes Logo mit den Buchstaben „G“ und „A“...
Nimm das erste Bild der Frau mit braunen Haaren, blauen Augen und einem neutralen Gesichtsausdruck…
Nimm das erste Bild der Frau mit braunen Haaren, blauen Augen und einem neutralen Gesichtsausdruck...

Best Practices

Mit diesen professionellen Strategien können Sie Ihre Ergebnisse von gut zu sehr gut verbessern.

  • Seien Sie sehr spezifisch:Je mehr Details Sie angeben, desto mehr Kontrolle haben Sie. Beschreiben Sie die Rüstung genauer, z. B. statt „Fantasy-Rüstung“: „aufwendige elfenhafte Plattenrüstung mit eingravierten silbernen Blattmustern, hohem Kragen und Schulterstücken in Form von Falkenflügeln“.
  • Kontext und Intention angeben:Erläutern Sie den Zweck des Bildes. Das Kontextverständnis des Modells beeinflusst die endgültige Ausgabe. Ein Beispiel: „Erstelle ein Logo für eine hochwertige, minimalistische Hautpflege-Marke“ liefert bessere Ergebnisse als „Erstelle ein Logo“.
  • Wiederholen und verfeinern:Erwarte nicht, dass du beim ersten Versuch ein perfektes Bild erhältst. Nutzen Sie die Konversationsfunktion des Modells, um kleine Änderungen vorzunehmen. Verwende Folge-Prompts wie „Das ist toll, aber kannst du die Beleuchtung etwas wärmer gestalten?“ oder „Lass alles so, aber ändere den Gesichtsausdruck der Figur zu einem ernsteren.“
  • Schritt-für-Schritt-Anleitung verwenden:Bei komplexen Szenen mit vielen Elementen sollten Sie Ihren Prompt in Schritte unterteilen. „Erstelle zuerst einen Hintergrund mit einem ruhigen, nebligen Wald bei Sonnenaufgang. Fügen Sie dann im Vordergrund einen moosbewachsenen alten Steinaltar hinzu. Stelle schließlich ein einzelnes, leuchtendes Schwert auf den Altar.“
  • Semantische negative Prompts verwenden: Anstatt „keine Autos“ zu sagen, beschreiben Sie die gewünschte Szene positiv: „eine leere, verlassene Straße ohne Anzeichen von Verkehr“.
  • Kamera steuern:Verwenden Sie fotografische und filmische Begriffe, um die Komposition zu steuern. Begriffe wie wide-angle shot, macro shot, low-angle perspective.

Beschränkungen

  • Die beste Leistung erzielen Sie mit den folgenden Sprachen: EN, es-MX, ja-JP, zh-CN, hi-IN.
  • Bei der Bildgenerierung werden keine Audio- oder Videoeingaben unterstützt.
  • Das Modell gibt nicht immer genau die Anzahl an Bildern aus, die der Nutzer explizit angefordert hat.
  • Das Modell funktioniert am besten mit bis zu drei Bildern als Eingabe.
  • Wenn Sie Text für ein Bild generieren, funktioniert Gemini am besten, wenn Sie zuerst den Text generieren und dann ein Bild mit dem Text anfordern.
  • Das Hochladen von Bildern von Kindern wird im EWR, in der Schweiz und im Vereinigten Königreich derzeit nicht unterstützt.
  • Alle generierten Bilder enthalten ein SynthID-Wasserzeichen.

Wann sollte Imagen verwendet werden?

Zusätzlich zu den integrierten Funktionen von Gemini zur Bildgenerierung können Sie über die Gemini API auch auf Imagen zugreifen, unser spezielles Modell zur Bildgenerierung.

Attribut Imagen Gemini Native Image
Vorteile Das bisher leistungsstärkste Modell zur Bildgenerierung. Empfohlen für fotorealistische Bilder, schärfere Klarheit, verbesserte Rechtschreibung und Typografie. Standardempfehlung
: Unübertroffene Flexibilität, kontextbezogene Informationen und einfache, maskenfreie Bearbeitung. Einzigartige Fähigkeit zur konversationellen Bearbeitung in mehreren Durchgängen.
Verfügbarkeit Allgemein verfügbar Vorabversion (Nutzung in der Produktion zulässig)
Latenz Niedrig Für Near-Realtime-Leistung optimiert. Höher. Für die erweiterten Funktionen ist mehr Rechenleistung erforderlich.
Kosten Kostengünstig für spezielle Aufgaben. 0,02 $ pro Bild bis 0,12 $pro Bild Tokenbasierte Preise. 30 $ pro 1 Million Tokens für die Bildausgabe (Bildausgabe mit 1.290 Tokens pro Bild pauschalisiert, bis zu 1.024 × 1.024 Pixel)
Empfohlene Aufgaben
  • Bildqualität, Fotorealismus, künstlerische Details oder bestimmte Stile (z.B. Impressionismus, Anime) haben höchste Priorität.
  • Branding und Stil einfließen lassen oder Logos und Produktdesigns generieren
  • Erweiterte Rechtschreib- oder Typografiekorrekturen werden generiert.
  • Verschachtelte Text- und Bildgenerierung für eine nahtlose Kombination von Text und Bildern.
  • Kombinieren Sie Creative-Elemente aus mehreren Bildern mit nur einem Prompt.
  • Sie können Bilder sehr präzise bearbeiten, einzelne Elemente mit einfachen Sprachbefehlen ändern und ein Bild iterativ bearbeiten.
  • Sie können ein bestimmtes Design oder eine bestimmte Textur von einem Bild auf ein anderes anwenden und dabei die Form und die Details des ursprünglichen Motivs beibehalten.

Imagen 4 sollte Ihr Standardmodell sein, wenn Sie mit Imagen Bilder generieren. Wählen Sie Imagen 4 Ultra für anspruchsvolle Anwendungsfälle oder wenn Sie die beste Bildqualität benötigen. Beachten Sie, dass jeweils nur ein Bild generiert werden kann.

Nächste Schritte