إنشاء الصور باستخدام Gemini

يمكن لـ Gemini إنشاء الصور ومعالجتها بشكل حواري. يمكنك تقديم طلب إلى Gemini باستخدام نص أو صور أو مزيج من الاثنين، ما يتيح لك إنشاء عناصر مرئية وتعديلها وتكرارها مع التحكّم فيها بشكل غير مسبوق:

  • Text-to-Image: يمكنك إنشاء صور عالية الجودة من أوصاف نصية بسيطة أو معقّدة.
  • صورة + تحويل النص إلى صورة (تعديل): قدِّم صورة واستخدِم طلبات نصية لإضافة عناصر أو إزالتها أو تعديلها أو تغيير النمط أو ضبط تدرّج الألوان.
  • تحويل صور متعددة إلى صورة واحدة (التركيب ونقل النمط): استخدِم صور إدخال متعددة لتركيب مشهد جديد أو نقل النمط من صورة إلى أخرى.
  • التحسين التكراري: يمكنك إجراء محادثة لتحسين صورتك تدريجيًا على مدار عدة جولات، وإجراء تعديلات صغيرة إلى أن تصبح مثالية.
  • عرض النصوص بدقة عالية: يمكنك إنشاء صور تحتوي على نصوص واضحة وموضّحة بشكل جيد، ما يجعلها مثالية للشعارات والأشكال التوضيحية والملصقات.

تتضمّن جميع الصور التي يتم إنشاؤها علامة SynthID المائية.

إنشاء الصور (من نص إلى صورة)

يوضّح الرمز التالي كيفية إنشاء صورة استنادًا إلى طلب وصفي.

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

Go

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
صورة من إنشاء الذكاء الاصطناعي لطبق من الموز الصغير
صورة من إنشاء الذكاء الاصطناعي لطبق من الموز الصغير في مطعم مستوحى من Gemini

تعديل الصور (تحويل النص والصورة إلى صورة)

تذكير: يُرجى التأكّد من امتلاكك الحقوق اللازمة لأي صور قبل تحميلها. يُرجى عدم إنشاء محتوى ينتهك حقوق الآخرين، بما في ذلك الفيديوهات أو الصور التي تتسبب في الخداع أو المضايقة والأذى. جدير بالذكر أنّ استخدامك لخدمة الذكاء الاصطناعي التوليدي هذه يخضع لسياسة الاستخدام المحظور.

لتعديل صورة، أضِف صورة كإدخال. يوضّح المثال التالي كيفية تحميل صور مشفّرة بتشفير base64. للحصول على معلومات حول الصور المتعددة والحِزم الأكبر وأنواع MIME المتوافقة، يُرجى الاطّلاع على صفحة فهم الصور.

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

Go

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
صورة من إنشاء الذكاء الاصطناعي لقطة تأكل موزة
صورة من إنشاء الذكاء الاصطناعي لقطة تأكل موزة صغيرة

أوضاع أخرى لإنشاء الصور

يتيح Gemini أوضاعًا أخرى للتفاعل مع الصور استنادًا إلى بنية الطلب والسياق، بما في ذلك:

  • النص إلى صور والنص (متداخل): يعرض صورًا مع نص ذي صلة.
    • مثال على الطلب: "أريد إنشاء وصفة مصوّرة لتحضير البايلا".
  • الصور والنص إلى صور ونص (متداخل): تستخدم هذه الميزة الصور والنصوص المُدخَلة لإنشاء صور ونصوص جديدة ذات صلة.
    • مثال على الطلب: (مع صورة لغرفة مفروشة) "ما هي ألوان الأرائك الأخرى التي يمكن استخدامها في مساحتي؟ هل يمكنك تعديل الصورة؟"
  • تعديل الصور في عدة مراحل (المحادثة): يمكنك مواصلة إنشاء الصور وتعديلها بشكل تفاعلي.
    • أمثلة على الطلبات: [حمِّل صورة سيارة زرقاء.] ، "حوِّل هذه السيارة إلى سيارة مكشوفة"، "غيِّر اللون إلى الأصفر".

الدليل الإرشادي لكتابة الطلبات والاستراتيجيات

تتطلّب إتقان ميزة إنشاء الصور باستخدام نموذج ‎2.5 Flash من Gemini الالتزام بمبدأ أساسي واحد:

صف المشهد، ولا تكتفِ بإدراج الكلمات الرئيسية. تتمثّل نقطة القوة الأساسية للنموذج في فهمه العميق للغة. سيؤدي استخدام فقرة سردية وصفية دائمًا تقريبًا إلى إنشاء صورة أفضل وأكثر اتساقًا من استخدام قائمة بكلمات غير مرتبطة.

طلبات إنشاء الصور

ستساعدك الاستراتيجيات التالية في إنشاء طلبات فعّالة للحصول على الصور التي تبحث عنها بالضبط.

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.

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()
صورة مقرّبة واقعية للغاية لخزّاف ياباني مسنّ...
صورة بورتريه مقرّبة وواقعية لخزّاف ياباني مسنّ...

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.

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()
ملصق على طراز "كاواي" يظهر فيه...
ملصق بأسلوب "كاواي" يظهر فيه دب باندا أحمر سعيد...

3- نص دقيق في الصور

يتفوّق Gemini في عرض النصوص. يجب أن يكون النص واضحًا، وأن يكون نمط الخط (وصفيًا)، وأن يكون التصميم العام واضحًا.

نموذج

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.

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()
أريد تصميم شعار عصري بسيط لمقهى باسم "The Daily Grind"...
أريد إنشاء شعار عصري وبسيط لمقهى اسمه "The Daily Grind"...

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.

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()
صورة منتج عالية الدقة تم التقاطها في استوديو لكوب قهوة سيراميك بسيط...
صورة منتج عالية الدقة ومضاءة في الاستوديو لكوب قهوة بسيط من السيراميك...

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.

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()
صورة بسيطة تعرض ورقة قيقب حمراء واحدة رقيقة...
صورة بسيطة تتضمّن ورقة قيقب حمراء واحدة رقيقة...

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.

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()
لوحة واحدة من كتاب مصوّر بأسلوب فني داكن ومثير...
لوحة واحدة من كتاب رسوم هزلية بأسلوب فني جريء ومظلم...

طلبات تعديل الصور

توضّح هذه الأمثلة كيفية تقديم صور إلى جانب طلباتك النصية لإجراء التعديلات وإنشاء التركيبات ونقل الأنماط.

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

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

الإدخال

الناتج

صورة واقعية لقطة زنجبيلية منفوشة.
صورة واقعية لقطة زنجبيلية ذات فرو طويل...
باستخدام صورة قطتي المرفقة، يُرجى إضافة قبعة ساحر صغيرة منسوجة...
باستخدام صورة قطتي المرفقة، يُرجى إضافة قبعة ساحر صغيرة منسوجة...

2. الطلاء الداخلي (إخفاء المعنى)

يمكنك تحديد "قناع" بشكل حواري لتعديل جزء معيّن من الصورة بدون التأثير في بقية الصورة.

نموذج

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

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

الإدخال

الناتج

لقطة واسعة لغرفة معيشة عصرية مضاءة جيدًا...
لقطة واسعة لغرفة معيشة حديثة ومضاءة جيدًا...
باستخدام صورة غرفة المعيشة المقدَّمة، غيِّر فقط الأريكة الزرقاء إلى أريكة تشيسترفيلد جلدية بنية قديمة...
باستخدام صورة غرفة المعيشة المقدَّمة، غيِّر فقط الأريكة الزرقاء إلى أريكة تشيسترفيلد عتيقة من الجلد البني...

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

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

الإدخال

الناتج

صورة فوتوغرافية واقعية وعالية الدقة لشارع مزدحم في المدينة...
صورة واقعية للغاية وعالية الدقة لشارع مزدحم في مدينة...
حوِّل الصورة المقدَّمة لشارع في مدينة حديثة ليلاً...
حوِّل الصورة المقدَّمة لشارع في مدينة حديثة ليلاً...

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

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

المعلومة 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."

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

المعلومة 1

المعلومة 2

الناتج

صورة احترافية لوجه امرأة بشعر بني وعينين زرقاوين...
صورة احترافية تبيّن وجه امرأة بشعر بني وعينَين زرقاوَين...
شعار بسيط وعصري يتضمّن الحرفين "G" و"A"...
شعار بسيط وعصري يتضمّن الحرفين "G" و"A"...
خذ الصورة الأولى للمرأة ذات الشعر البني والعينين الزرقاوين وتعبير الوجه المحايد...
أريد الصورة الأولى للمرأة ذات الشعر البني والعينين الزرقاوين وتعابير الوجه المحايدة...

أفضل الممارسات

لتحسين نتائجك، يمكنك دمج هذه الاستراتيجيات الاحترافية في سير عملك.

  • كن دقيقًا للغاية: كلما قدّمت تفاصيل أكثر، زادت إمكانية التحكّم. بدلاً من "درع خيالي"، يمكنك وصفه على النحو التالي: "درع ألواح مزخرف خاص بالجنيات، منقوش عليه أنماط أوراق فضية، مع ياقة عالية وواقيات كتف على شكل أجنحة صقر".
  • توفير السياق والنية: اشرح الغرض من الصورة. سيؤثر فهم النموذج للسياق في الناتج النهائي. على سبيل المثال، سيؤدي طلب "إنشاء شعار لعلامة تجارية فاخرة وبسيطة للعناية بالبشرة" إلى نتائج أفضل من مجرد طلب "إنشاء شعار".
  • التكرار والتحسين: لا تتوقّع الحصول على صورة مثالية من المحاولة الأولى. استخدِم الطبيعة الحوارية للنموذج لإجراء تغييرات صغيرة. يمكنك متابعة المحادثة بطلبات مثل "هذا رائع، ولكن هل يمكنك جعل الإضاءة أكثر دفئًا؟" أو "أريد إبقاء كل شيء كما هو، ولكن تغيير تعابير وجه الشخصية لتكون أكثر جدية".
  • استخدام تعليمات مفصّلة: بالنسبة إلى المشاهد المعقّدة التي تتضمّن عناصر كثيرة، قسِّم طلبك إلى خطوات. "أريد أولاً إنشاء خلفية لغابة هادئة ضبابية في الفجر. بعد ذلك، أضِف في المقدّمة مذبحًا قديمًا من الحجر مغطّى بالطحلب. أخيرًا، ضَع سيفًا واحدًا متوهجًا فوق المذبح".
  • استخدام "مطالبات سلبية دلالية": بدلاً من قول "لا أريد سيارات"، يمكنك وصف المشهد المطلوب بشكل إيجابي: "شارع خالٍ ومهجور لا تظهر فيه أي علامات على حركة المرور".
  • التحكّم في الكاميرا: استخدِم لغة التصوير الفوتوغرافي والسينمائي للتحكّم في التركيبة. عبارات مثل wide-angle shot وmacro shot وlow-angle perspective

القيود

  • للحصول على أفضل أداء، استخدِم اللغات التالية: الإنجليزية والإسبانية (المكسيك) واليابانية والصينية والهندية.
  • لا تتيح ميزة إنشاء الصور إدخال مقاطع صوتية أو فيديوهات.
  • لن يلتزم النموذج دائمًا بالعدد الدقيق لنتائج الصور التي طلبها المستخدم بشكل صريح.
  • يعمل النموذج بشكل أفضل مع ما يصل إلى 3 صور كمدخلات.
  • عند إنشاء نص لصورة، يعمل Gemini بشكل أفضل إذا أنشأت النص أولاً ثم طلبت صورة تتضمّن النص.
  • لا يمكن حاليًا تحميل صور للأطفال في المنطقة الاقتصادية الأوروبية وسويسرا والمملكة المتحدة.
  • تتضمّن جميع الصور التي يتم إنشاؤها علامة SynthID المائية.

حالات استخدام Imagen

بالإضافة إلى استخدام إمكانات إنشاء الصور المضمّنة في Gemini، يمكنك أيضًا الاستفادة من Imagen، نموذجنا المتخصّص في إنشاء الصور، من خلال Gemini API.

السمة Imagen صورة Gemini الأصلية
نقاط القوة أكثر نموذج لإنشاء الصور تطورًا حتى الآن يُنصح به لإنشاء صور واقعية، ووضوح أعلى، وتحسين الإملاء والكتابة. الاقتراح التلقائي:
مرونة لا مثيل لها وفهم سياقي وتعديل بسيط بدون إخفاء أي جزء من الصورة تتضمّن ميزة التعديل عبر المحادثة إمكانات فريدة تتيح إجراء تعديلات متعددة في المحادثة نفسها.
مدى التوفّر متوفر للجمهور العام معاينة (يُسمح بالاستخدام في مرحلة الإنتاج)
وقت الاستجابة منخفضة تم تحسينها لتحقيق أداء شبه فوري. أعلى. تتطلّب إمكاناتها المتقدّمة المزيد من العمليات الحسابية.
التكلفة فعّالة من حيث التكلفة للمهام المتخصّصة من 0.02 دولار أمريكي لكل صورة إلى 0.12 دولار أمريكي لكل صورة التسعير المستند إلى الرموز المميزة ‫30 دولار أمريكي لكل مليون رمز مميز لناتج الصور (يتم ترميز ناتج الصور بمعدل 1290 رمز مميز لكل صورة، وبحد أقصى 1024x1024 بكسل)
المهام المقترَحة
  • تُعدّ جودة الصورة أو الواقعية الفوتوغرافية أو التفاصيل الفنية أو الأساليب المحدّدة (مثل الانطباعية أو الأنمي) من أهم الأولويات.
  • إضافة هوية العلامة التجارية أو الأسلوب أو إنشاء شعارات وتصاميم منتجات
  • إنشاء تدقيق إملائي أو طباعي متقدّم
  • إنشاء نصوص وصور متداخلة لدمج النصوص والصور بسلاسة
  • يمكنك دمج عناصر تصميمية من صور متعددة باستخدام طلب واحد.
  • إجراء تعديلات دقيقة جدًا على الصور وتعديل العناصر الفردية باستخدام أوامر لغوية بسيطة والعمل بشكل متكرّر على صورة
  • تطبيق تصميم أو زخرفة معيّنة من صورة إلى أخرى مع الحفاظ على شكل وتفاصيل العنصر الأصلي

ننصحك باستخدام Imagen 4 لإنشاء الصور باستخدام Imagen. اختَر Imagen 4 Ultra لحالات الاستخدام المتقدّمة أو عندما تحتاج إلى أفضل جودة للصور (يُرجى العِلم أنّه يمكنك إنشاء صورة واحدة فقط في كل مرة).

الخطوات التالية

  • يمكنك العثور على المزيد من الأمثلة ونماذج الرموز البرمجية في دليل كتاب الطبخ.
  • اطّلِع على دليل Veo لمعرفة كيفية إنشاء فيديوهات باستخدام Gemini API.
  • لمزيد من المعلومات حول نماذج Gemini، يُرجى الاطّلاع على نماذج Gemini.