Gemini 2.5 Flash Image 미리보기는 다양한 유형의 이미지 편집을 지원합니다.
이미지 수정
이미지 생성(gemini-2.5-flash-image-preview)을 위한 Gemini 2.5 Flash Image의 공개 프리뷰는 이미지를 생성하는 것 외에도 편집하는 기능을 지원합니다. 이 공개 미리보기 버전을 통해 Gemini 2.5 Flash 이미지는 이미지 편집 및 멀티턴 편집을 개선하고 더 유연하고 제한적이지 않은 사용자 환경을 제공하는 업데이트된 안전 필터를 포함합니다.
다음과 같은 형식과 기능을 지원합니다.
이미지 편집(텍스트 및 이미지 간)
프롬프트 예시: '이 이미지를 만화처럼 보이도록 수정해 줘.'
프롬프트 예시: [고양이 이미지] + [베개 이미지] + '이 베개에 내 고양이 십자수를 만들어 줘.'
멀티턴 이미지 편집(채팅)
프롬프트 예시: [파란색 자동차 이미지를 업로드하세요.] '이 차를 컨버터블로 바꿔 줘.' '이제 색상을 노란색으로 바꿔 줘.'
'스포일러를 추가해 줘.'
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
fromgoogleimportgenaifromgoogle.genai.typesimportGenerateContentConfig,ModalityfromPILimportImagefromioimportBytesIOclient=genai.Client()# Using an image of Eiffel tower, with fireworks in the background.image=Image.open("test_resources/example-image-eiffel-tower.png")response=client.models.generate_content(model="gemini-2.5-flash-image-preview",contents=[image,"Edit this image to make it look like a cartoon."],config=GenerateContentConfig(response_modalities=[Modality.TEXT,Modality.IMAGE]),)forpartinresponse.candidates[0].content.parts:ifpart.text:print(part.text)elifpart.inline_data:image=Image.open(BytesIO((part.inline_data.data)))image.save("output_folder/bw-example-image.png")# Example response:# Here's the cartoon-style edit of the image:# Cartoon-style edit:# - Simplified the Eiffel Tower with bolder lines and slightly exaggerated proportions.# - Brightened and saturated the colors of the sky, fireworks, and foliage for a more vibrant, cartoonish look.# ....
REST
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
curl-XPOST\-H"Authorization: Bearer $(gcloudauthprint-access-token)"\-H"Content-Type: application/json"\https://${API_ENDPOINT}:generateContent\-d'{ "contents": { "role": "USER", "parts": [ {"file_data": { "mime_type": "image/jpg", "file_uri": "<var>FILE_NAME</var>" } }, {"text": "Convert this photo to black and white, in a cartoonish style."}, ] }, "generation_config": { "response_modalities": ["TEXT", "IMAGE"], }, "safetySettings": { "method": "PROBABILITY", "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, }'2>/dev/null>response.json
Gemini가 설명을 기반으로 이미지를 생성합니다. 이 프로세스는 몇 초 정도 걸리지만 용량에 따라 비교적 느릴 수 있습니다.
멀티턴 이미지 편집
Gemini 2.5 Flash Image 미리보기는 개선된 멀티턴 편집도 지원하므로 편집된 이미지 대답을 받은 후 변경사항을 적용하여 모델에 응답할 수 있습니다.
이렇게 하면 이미지 대화를 계속 수정할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Edit images with Gemini\n\n| **Preview**\n|\n|\n| This product or feature is a Generative AI Preview offering, subject to\n| the \"Pre-GA Offerings Terms\" of the\n| [Google Cloud Service Specific Terms](/terms/service-terms),\n| as well as the\n| [Additional Terms for Generative AI Preview Products](/trustedtester/aitos). For this\n| Generative AI Preview offering, Customers may elect to use it for\n| production or commercial purposes, or disclose Generated Output to\n| third-parties, and may process personal data as outlined in the\n| [Cloud Data Processing\n| Addendum](/terms/data-processing-addendum),\n| subject to the obligations and restrictions described in the agreement\n| under which you access Google Cloud. Pre-GA products are available \"as is\"\n| and might have limited support. For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\n\u003cbr /\u003e\n\nGemini 2.5 Flash Image Preview supports multiple types of image editing.\n| **Note:** Image editing and multi-turn image editing are only supported in `gemini-2.5-flash-image-preview`, not `gemini-2.5-flash`.\n\nImage editing\n-------------\n\n| To see an example of image editing with Gemini,\n| run the \"Gemini 2.5 Flash Image Generation in Vertex AI\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_5_image_gen.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fgetting-started%2Fintro_gemini_2_5_image_gen.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fgetting-started%2Fintro_gemini_2_5_image_gen.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_5_image_gen.ipynb)\n\nGemini 2.5 Flash Image's public preview for image generation\n(`gemini-2.5-flash-image-preview`) supports the ability to edit\nimages in addition generating them. With this public preview release,\nGemini 2.5 Flash Image supports improved editing of images and\nmulti-turn editing and contains updated safety filters that provide a more\nflexible and less restrictive user experience.\n\nIt supports the following modalities and capabilities:\n\n- Image editing (text and image to image)\n\n - **Example prompt:** \"Edit this image to make it look like a cartoon\"\n - **Example prompt:** \\[image of a cat\\] + \\[image of a pillow\\] + \"Create a cross stitch of my cat on this pillow.\"\n- Multi-turn image editing (chat)\n\n - **Example prompts:** \\[upload an image of a blue car.\\] \"Turn this car into a convertible.\" \"Now change the color to yellow.\" \"Add a spoiler.\"\n\nEdit an image\n-------------\n\n### Console\n\nTo edit images:\n\n1. Open [**Vertex AI Studio \\\u003e Create prompt**](https://console.cloud.google.com/vertex-ai/studio/multimodal).\n2. Click **Switch model** and select **`gemini-2.5-flash-image-preview`** from the menu.\n3. In the **Outputs** panel, select **Image and text** from the drop-down menu.\n4. Click **Insert media** (add_photo_alternate) and select a source from the menu, then follow the dialog's instructions.\n5. Write what edits you want to make to the image in the **Write a prompt** text area.\n6. Click the **Prompt** (send) button.\n\n\nGemini will generate an edited version of the provided image based on\nyour description. This process should take a few seconds, but may be\ncomparatively slower depending on capacity.\n\n### Python\n\n#### Install\n\n```\npip install --upgrade google-genai\n```\n\n\nTo learn more, see the\n[SDK reference documentation](https://googleapis.github.io/python-genai/).\n\n\nSet environment variables to use the Gen AI SDK with Vertex AI:\n\n```bash\n# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values\n# with appropriate values for your project.\nexport GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT\nexport GOOGLE_CLOUD_LOCATION=global\nexport GOOGLE_GENAI_USE_VERTEXAI=True\n```\n\n\u003cbr /\u003e\n\n from google import genai\n from google.genai.types import GenerateContentConfig, Modality\n from PIL import Image\n from io import BytesIO\n\n client = genai.Client()\n\n # Using an image of Eiffel tower, with fireworks in the background.\n image = Image.open(\"test_resources/example-image-eiffel-tower.png\")\n\n response = client.models.generate_content(\n model=\"gemini-2.5-flash-image-preview\",\n contents=[image, \"Edit this image to make it look like a cartoon.\"],\n config=GenerateContentConfig(response_modalities=[Modality.TEXT, Modality.IMAGE]),\n )\n for part in response.candidates[0].content.parts:\n if part.text:\n print(part.text)\n elif part.inline_data:\n image = Image.open(BytesIO((part.inline_data.data)))\n image.save(\"output_folder/bw-example-image.png\")\n # Example response:\n # Here's the cartoon-style edit of the image:\n # Cartoon-style edit:\n # - Simplified the Eiffel Tower with bolder lines and slightly exaggerated proportions.\n # - Brightened and saturated the colors of the sky, fireworks, and foliage for a more vibrant, cartoonish look.\n # ....\n\n### REST\n\n\nRun the following command in the terminal to create or overwrite this file in\nthe current directory: \n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n https://${API_ENDPOINT}:generateContent \\\n -d '{\n \"contents\": {\n \"role\": \"USER\",\n \"parts\": [\n {\"file\u003c_da\u003eta\":\u003c {\n \u003e \"mime_type\": \"image/jpg\",\n \"file_uri\": \"varFILE_NAME/var\"\n }\n },\n {\"text\": \"Convert this photo to black and white, in a cartoonish style.\"},\n ]\n\n },\n \"generation_config\": {\n \"response_modalities\": [\"TEXT\", \"IMAGE\"]\u003e,\n },\n \u003e \"safetySettings\": {\n \"method\": \"PROBABILITY\",\n \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n \"threshold\": \"BLOCK_MEDIUM_AND_ABOVE\"\n },\n }' 2/dev/null response.json\n\n| **Note:** You **must** include `responseModalities: [\"TEXT\", \"IMAGE\"]` in your configuration. Image-only output is not supported with these models.\n\n\nGemini will generate an image based on your description. This\nprocess should take a few seconds, but may be comparatively slower depending on\ncapacity.\n\n\u003cbr /\u003e\n\nMulti-turn image editing\n------------------------\n\nGemini 2.5 Flash Image Preview also supports improved multi-turn editing, allowing\nyou to respond to the model with changes after receiving an edited image response.\nThis will allow you to continue to make edits to the image conversationally.\n\nNote that is recommended to limit the entire request file size to 50MB maximum.\n\nTo test out multi-turn image editing, try our\n[Gemini 2.5 Flash Image Preview notebook](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_5_image_gen.ipynb)."]]