تولید تصویر با جمینی

Gemini می تواند تصاویر را به صورت مکالمه تولید و پردازش کند. می‌توانید از Gemini متن، تصاویر یا ترکیبی از هر دو را درخواست کنید تا بتوانید تصاویر را با کنترل بی‌سابقه ایجاد، ویرایش و تکرار کنید:

  • متن به تصویر: تصاویر با کیفیت بالا را از توضیحات متنی ساده یا پیچیده ایجاد کنید.
  • تصویر + متن به تصویر (ویرایش): یک تصویر ارائه دهید و از پیام های متنی برای افزودن، حذف یا اصلاح عناصر، تغییر سبک یا تنظیم درجه بندی رنگ استفاده کنید.
  • چند تصویر به تصویر (Composition & Style Transfer): از تصاویر ورودی متعدد برای نوشتن صحنه جدید یا انتقال سبک از یک تصویر به تصویر دیگر استفاده کنید.
  • پالایش تکراری: در یک مکالمه شرکت کنید تا به تدریج تصویر خود را در چندین چرخش اصلاح کنید و تنظیمات کوچکی را انجام دهید تا زمانی که کامل شود.
  • رندر متن با دقت بالا: تصاویری را با دقت ایجاد کنید که حاوی متنی خوانا و با جایگذاری مناسب هستند، ایده آل برای لوگوها، نمودارها و پوسترها.

همه تصاویر تولید شده شامل یک علامت SynthID هستند.

تولید تصویر (متن به تصویر)

کد زیر نحوه تولید یک تصویر بر اساس یک دستور توصیفی را نشان می دهد.

پایتون

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")

جاوا اسکریپت

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();

برو

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)
      }
  }
}

استراحت

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
تصویر تولید شده توسط هوش مصنوعی از ظرف نانویی موز
تصویر تولید شده توسط هوش مصنوعی از یک ظرف نانویی موز در رستورانی با تم Gemini

ویرایش تصویر (متن و تصویر به تصویر)

یادآوری : مطمئن شوید که حقوق لازم را برای هر تصویری که آپلود می کنید دارید. محتوایی تولید نکنید که حقوق دیگران را نقض می‌کند، از جمله ویدیوها یا تصاویری که فریب می‌دهند، آزار می‌دهند یا آسیب می‌زنند. استفاده شما از این سرویس هوش مصنوعی مولد تابع خط مشی استفاده ممنوع ما است.

برای انجام ویرایش تصویر، یک تصویر را به عنوان ورودی اضافه کنید. مثال زیر آپلود تصاویر کدگذاری شده base64 را نشان می دهد. برای تصاویر متعدد، بارهای بزرگتر و انواع MIME پشتیبانی شده، صفحه درک تصویر را بررسی کنید.

پایتون

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")

جاوا اسکریپت

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();

برو

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)
     }
 }
}

استراحت

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
تصویری که توسط هوش مصنوعی از یک گربه در حال خوردن موز آنانو ساخته شده است
تصویر تولید شده توسط هوش مصنوعی از گربه در حال خوردن یک موز نانو

سایر حالت های تولید تصویر

Gemini از سایر حالت های تعامل تصویر بر اساس ساختار و زمینه سریع پشتیبانی می کند، از جمله:

  • متن به تصویر(ها) و متن (میانبر): تصاویر را با متن مرتبط خروجی می دهد.
    • درخواست مثال: "یک دستور العمل مصور برای پائلا ایجاد کنید."
  • تصویر(ها) و متن به تصویر(ها) و نوشتار (میانبر) : از تصاویر ورودی و متن برای ایجاد تصاویر و متن مرتبط جدید استفاده می کند.
    • اعلان مثال: (با تصویر یک اتاق مبله) "مبل های چه رنگ دیگری در فضای من کار می کنند؟ آیا می توانید تصویر را به روز کنید؟"
  • ویرایش تصویر چند نوبتی (چت): به تولید و ویرایش تصاویر به صورت مکالمه ادامه دهید.
    • به عنوان مثال درخواست می کند: [تصویر یک ماشین آبی را آپلود کنید.] , "Turn this car into a convertible.", "Now change the color to yellow."

راهنما و راهبردهای تشویقی

تسلط بر Gemini 2.5 Flash Image Generation با یک اصل اساسی شروع می شود:

صحنه را توصیف کنید، فقط کلمات کلیدی را فهرست نکنید. نقطه قوت اصلی این مدل درک عمیق زبان آن است. یک پاراگراف روایی و توصیفی تقریباً همیشه تصویری بهتر و منسجم‌تر از فهرستی از کلمات جدا شده ایجاد می‌کند.

درخواست هایی برای تولید تصاویر

استراتژی‌های زیر به شما کمک می‌کنند تا اعلان‌های مؤثری برای ایجاد دقیقاً تصاویری که به دنبال آن هستید ایجاد کنید.

1. صحنه های فوتورئالیستی

برای تصاویر واقعی، از اصطلاحات عکاسی استفاده کنید. زوایای دوربین، انواع لنزها، نور و جزئیات دقیق را ذکر کنید تا مدل را به سمت یک نتیجه واقعی عکس هدایت کنید.

الگو

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.

اعلان

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.

پایتون

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()
پرتره کلوزآپ فوتورئالیستی از یک سرامیست سالخورده ژاپنی...
پرتره کلوزآپ فوتورئالیستی از یک سرامیست سالخورده ژاپنی...

2. تصاویر و برچسب های تلطیف شده

برای ایجاد استیکرها، نمادها یا دارایی‌ها، در مورد سبک صریح باشید و یک پس‌زمینه شفاف درخواست کنید.

الگو

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.

اعلان

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.

پایتون

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()
برچسبی به سبک کاوائی با رنگ قرمز شاد...
برچسبی به سبک کاوائی از یک پاندا سرخ شاد...

3. متن دقیق در تصاویر

جمینی در ارائه متن برتری دارد. در مورد متن، سبک فونت (به صورت توصیفی) و طرح کلی شفاف باشید.

الگو

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].

اعلان

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.

پایتون

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()
یک لوگوی مدرن و مینیمالیستی برای یک کافی شاپ به نام «دیلی گرایند» بسازید...
یک لوگوی مدرن و مینیمالیستی برای یک کافی شاپ به نام «دیلی گرایند» بسازید...

4. مدل های محصول و عکاسی تجاری

ایده آل برای ایجاد عکس های تمیز و حرفه ای از محصول برای تجارت الکترونیک، تبلیغات یا نام تجاری.

الگو

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].

اعلان

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.

پایتون

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()
عکس محصول با وضوح بالا و نور استودیویی از یک لیوان قهوه سرامیکی مینیمال...
عکس محصول با وضوح بالا و نور استودیویی از یک لیوان قهوه سرامیکی مینیمال...

5. طراحی فضای مینیمالیستی و نگاتیو

عالی برای ایجاد پس‌زمینه برای وب‌سایت‌ها، ارائه‌ها یا مطالب بازاریابی که در آن متن روی هم قرار می‌گیرد.

الگو

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].

اعلان

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.

پایتون

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()
یک ترکیب مینیمالیستی با یک برگ افرا قرمز تک و ظریف...
یک ترکیب مینیمالیستی با یک برگ افرا قرمز تک و ظریف...

6. هنر متوالی (پانل کمیک / استوری برد)

برای ایجاد پانل‌هایی برای داستان سرایی بصری، بر اساس سازگاری شخصیت و توصیف صحنه است.

الگو

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].

اعلان

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.

پایتون

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()
پانل تک بوک کمیک به سبک هنری نوآر...
پانل تک بوک کمیک به سبک هنری نوآر...

درخواست برای ویرایش تصاویر

این مثال‌ها نشان می‌دهند که چگونه می‌توان تصاویر را در کنار پیام‌های متنی برای ویرایش، ترکیب‌بندی و انتقال سبک ارائه کرد.

1. اضافه کردن و حذف عناصر

یک تصویر ارائه دهید و تغییر خود را شرح دهید. این مدل با سبک، نور و پرسپکتیو تصویر اصلی مطابقت دارد.

الگو

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].

اعلان

"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."

پایتون

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()

ورودی

خروجی

تصویر واقعی از یک گربه زنجبیلی کرکی..
عکس واقعی از یک گربه زنجبیلی کرکی...
با استفاده از تصویر ارائه شده از گربه من، لطفا یک کلاه جادوگر کوچک بافتنی اضافه کنید...
با استفاده از تصویر ارائه شده از گربه من، لطفا یک کلاه جادوگر کوچک بافتنی اضافه کنید...

2. Inpainting (پوشش معنایی)

به صورت مکالمه یک «ماسک» تعریف کنید تا قسمت خاصی از یک تصویر را ویرایش کنید و بقیه را دست نخورده بگذارید.

الگو

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.

اعلان

"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."

پایتون

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()

ورودی

خروجی

تصویری وسیع از یک اتاق نشیمن مدرن و با نور کافی...
تصویری وسیع از یک اتاق نشیمن مدرن و با نور کافی...
با استفاده از تصویر ارائه شده از یک اتاق نشیمن، فقط مبل آبی را به یک مبل چسترفیلد وینتیج و قهوه ای تغییر دهید...
با استفاده از تصویر ارائه شده از یک اتاق نشیمن، فقط مبل آبی را به یک مبل چسترفیلد وینتیج و قهوه ای تغییر دهید...

3. انتقال سبک

یک تصویر ارائه دهید و از مدل بخواهید محتوای خود را با سبک هنری متفاوت بازسازی کند.

الگو

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].

اعلان

"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."

پایتون

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()

ورودی

خروجی

عکس واقعی و با وضوح بالا از یک خیابان شلوغ شهر...
عکس واقعی و با وضوح بالا از یک خیابان شلوغ شهر...
تغییر عکس ارائه شده از یک خیابان شهری مدرن در شب...
تغییر عکس ارائه شده از یک خیابان شهری مدرن در شب...

4. ترکیب پیشرفته: ترکیب چندین تصویر

چندین تصویر را به عنوان زمینه برای ایجاد یک صحنه جدید و ترکیبی ارائه دهید. این برای ماکت های محصول یا کلاژهای خلاقانه مناسب است.

الگو

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].

اعلان

"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."

پایتون

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()

ورودی 1

ورودی 2

خروجی

عکس حرفه ای از لباس تابستانی گلدار آبی...
عکس حرفه ای از لباس تابستانی گلدار آبی...
عکسی از تمام بدن زنی که موهایش را نان بسته است...
عکسی از تمام بدن زنی که موهایش را نان بسته است...
یک عکس مد حرفه ای تجارت الکترونیک بسازید...
یک عکس مد حرفه ای تجارت الکترونیک بسازید...

5. حفظ جزئیات با وفاداری بالا

برای اطمینان از حفظ جزئیات مهم (مانند چهره یا لوگو) در طول ویرایش، آنها را با جزئیات کامل همراه با درخواست ویرایش خود شرح دهید.

الگو

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].

اعلان

"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."

پایتون

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()

ورودی 1

ورودی 2

خروجی

هد شات حرفه ای از زنی با موهای قهوه ای و چشمان آبی...
هد شات حرفه ای از زنی با موهای قهوه ای و چشمان آبی...
لوگوی ساده و مدرن با حروف "G" و "A"...
لوگوی ساده و مدرن با حروف "G" و "A"...
اولین تصویر از زنی با موهای قهوه ای، چشمان آبی و حالت خنثی را بگیرید...
اولین تصویر از زنی با موهای قهوه ای، چشمان آبی و حالت خنثی را بگیرید...

بهترین شیوه ها

برای ارتقای نتایج خود از خوب به عالی، این استراتژی های حرفه ای را در جریان کاری خود بگنجانید.

  • بیش از حد خاص باشید: هر چه جزئیات بیشتری ارائه دهید، کنترل بیشتری خواهید داشت. به‌جای «زره فانتزی»، آن را توصیف کنید: «زره جنی پرآذین، حکاکی‌شده با طرح‌های برگ نقره‌ای، با یقه‌ای بلند و بالکن‌هایی به شکل بال‌های شاهین».
  • ارائه زمینه و هدف: هدف تصویر را توضیح دهید. درک مدل از زمینه بر خروجی نهایی تأثیر خواهد گذاشت. به عنوان مثال، «ایجاد لوگو برای یک برند مراقبت از پوست سطح بالا و مینیمالیستی» نتایج بهتری نسبت به «ایجاد لوگو» به همراه خواهد داشت.
  • Iterate and Refine: انتظار نداشته باشید که در اولین تلاش یک تصویر عالی داشته باشید. از ماهیت محاوره ای مدل برای ایجاد تغییرات کوچک استفاده کنید. با اعلان هایی مانند "این عالی است، اما آیا می توانید نور را کمی گرم تر کنید؟" یا "همه چیز را یکسان نگه دارید، اما بیان شخصیت را تغییر دهید تا جدی تر باشد."
  • از دستورالعمل های گام به گام استفاده کنید: برای صحنه های پیچیده با عناصر زیاد، درخواست خود را به مراحل تقسیم کنید. "ابتدا، پس‌زمینه‌ای از یک جنگل آرام و مه آلود در سپیده‌دم ایجاد کنید. سپس، در پیش‌زمینه، یک محراب سنگی باستانی پوشیده از خزه را اضافه کنید. در نهایت، یک شمشیر منفرد و درخشان را در بالای محراب قرار دهید."
  • از «پیام‌های منفی معنایی» استفاده کنید: به‌جای گفتن «بدون ماشین»، صحنه مورد نظر را مثبت توصیف کنید: «خیابان خالی و متروک و بدون علائم ترافیک».
  • کنترل دوربین: از زبان عکاسی و سینمایی برای کنترل ترکیب بندی استفاده کنید. عباراتی مانند wide-angle shot ، macro shot ، low-angle perspective .

محدودیت ها

  • برای بهترین عملکرد، از زبان‌های زیر استفاده کنید: EN، es-MX، ja-JP، zh-CN، hi-IN.
  • تولید تصویر از ورودی های صوتی یا تصویری پشتیبانی نمی کند.
  • این مدل همیشه از تعداد دقیق خروجی های تصویری که کاربر صراحتاً درخواست کرده است، پیروی نمی کند.
  • این مدل با حداکثر 3 تصویر به عنوان ورودی بهترین کار را دارد.
  • هنگام تولید متن برای یک تصویر، Gemini بهترین کار را دارد اگر ابتدا متن را تولید کنید و سپس تصویری را با متن درخواست کنید.
  • آپلود تصاویر کودکان در حال حاضر در کشورهای منطقه اقتصادی اروپا، چین و بریتانیا پشتیبانی نمی شود.
  • همه تصاویر تولید شده شامل یک علامت SynthID هستند.

زمان استفاده از Imagen

علاوه بر استفاده از قابلیت‌های تولید تصویر داخلی Gemini، می‌توانید از طریق Gemini API به Imagen ، مدل تولید تصویر تخصصی ما نیز دسترسی داشته باشید.

صفت Imagen تصویر بومی جمینی
نقاط قوت تواناترین مدل تولید تصویر تا به امروز. برای تصاویر واقعی، وضوح واضح تر، املا و تایپوگرافی بهبود یافته توصیه می شود. توصیه پیش فرض
انعطاف پذیری بی نظیر، درک متنی، و ویرایش ساده و بدون ماسک. قابلیت منحصر به فرد ویرایش مکالمه چند نوبتی.
در دسترس بودن به طور کلی در دسترس است پیش نمایش (مصرف تولید مجاز است)
تأخیر کم . بهینه شده برای عملکرد نزدیک به زمان واقعی. بالاتر. محاسبات بیشتری برای قابلیت های پیشرفته آن مورد نیاز است.
هزینه مقرون به صرفه برای کارهای تخصصی. 0.02 دلار/تصویر تا 0.12 دلار/تصویر قیمت گذاری مبتنی بر توکن 30 دلار به ازای هر 1 میلیون توکن برای خروجی تصویر (خروجی تصویر با 1290 توکن در هر تصویر مسطح، تا 1024x1024 پیکسل توکن شده است)
وظایف توصیه شده
  • کیفیت تصویر، فوتورئالیسم، جزئیات هنری یا سبک‌های خاص (مثلاً امپرسیونیسم، انیمه) اولویت‌های اصلی هستند.
  • القای نام تجاری، سبک، یا تولید لوگوها و طرح های محصول.
  • ایجاد املا یا تایپوگرافی پیشرفته.
  • تولید متن و تصویر به هم پیوسته برای ترکیب یکپارچه متن و تصاویر.
  • عناصر خلاقانه از چندین تصویر را با یک درخواست ترکیب کنید.
  • ویرایش های بسیار خاص را روی تصاویر انجام دهید، عناصر فردی را با دستورات زبانی ساده تغییر دهید و به طور مکرر روی یک تصویر کار کنید.
  • با حفظ فرم و جزئیات سوژه اصلی، طرح یا بافت خاصی را از یک تصویر به تصویر دیگر اعمال کنید.

Imagen 4 باید مدل اصلی شما باشد که شروع به تولید تصاویر با Imagen می کند. برای موارد استفاده پیشرفته یا زمانی که به بهترین کیفیت تصویر نیاز دارید، Imagen 4 Ultra را انتخاب کنید (توجه داشته باشید که فقط می توانید یک تصویر را در یک زمان تولید کنید).

بعدش چی