Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
La versión preliminar de Gemini 2.5 Flash Image admite varios tipos de edición de imágenes.
Edición de imágenes
La versión preliminar pública de Gemini 2.5 Flash Image para la generación de imágenes (gemini-2.5-flash-image-preview) admite la capacidad de editar imágenes además de generarlas. Con esta versión de vista previa pública, Gemini 2.5 Flash Image admite la edición mejorada de imágenes y la edición en varios turnos, y contiene filtros de seguridad actualizados que brindan una experiencia del usuario más flexible y menos restrictiva.
Admite las siguientes modalidades y capacidades:
Edición de imágenes (texto a imagen y de imagen a imagen)
Ejemplo de instrucción: “Edita esta imagen para que parezca una caricatura”.
Ejemplo de instrucción: [Imagen de un gato] + [Imagen de una almohada] + "Crea un punto de cruz de mi gato en esta almohada".
Edición de imágenes de varios turnos (chat)
Ejemplos de instrucciones: [Sube una imagen de un auto azul]. "Convierte este auto en un convertible". "Ahora cambia el color a amarillo".
“Agrega un spoiler”.
Haz clic en Cambiar modelo y selecciona gemini-2.5-flash-image-preview en el menú.
En el panel Salidas, selecciona Imagen y texto en el menú desplegable.
Haz clic en Insertar medios (add_photo_alternate) y selecciona una fuente en el menú. Luego, sigue las instrucciones del diálogo.
Escribe qué ediciones quieres hacerle a la imagen en el área de texto Escribe una instrucción.
Haz clic en el botón Instrucción (send).
Gemini generará una versión editada de la imagen proporcionada según tu descripción. Este proceso debería tardar unos segundos, pero puede ser comparativamente más lento según la capacidad.
Establece variables de entorno para usar el SDK de IA generativa con Vertex AI:
# 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
Ejecuta el siguiente comando en la terminal para crear o reemplazar este archivo en el directorio actual:
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 generará una imagen en función de tu descripción. Este proceso debería tardar unos segundos, pero puede ser comparativamente más lento según la capacidad.
Edición de imágenes de varios turnos
La versión preliminar de Gemini 2.5 Flash Image también admite una edición de varios turnos mejorada, lo que te permite responder al modelo con cambios después de recibir una respuesta de imagen editada.
Esto te permitirá seguir editando la imagen de forma conversacional.
Ten en cuenta que se recomienda limitar el tamaño total del archivo de solicitud a un máximo de 50 MB.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-10 (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)."]]