
Photo by the author Twins (nano-banana authourport)
# Entry
Generating image with generative artificial intelligence has become a widely used tool for both natural persons and companies, which allows them to immediately create intended visualizations without the need for specialist knowledge. Basically, these tools can speed up the tasks that would otherwise take a significant amount of time, filling them in just a second.
Along with the progress of technology and competition, many up-to-date, advanced painting generation products were issued, such as Stable diffusionIN MidjourneyIN WITHIN PictureAnd many others. Everyone offers users unique advantages. However, Google has recently had a significant impact on the landscape of image generation along with the release Flash Gemini’s image 2.5 (or nano-banana).
Nano-Banana is an advanced model of generating and editing Google image, containing possibilities such as realistic image creation, multiple mixing of images, character cohesion, directed quick transformations based on quick quick and public availability. The model offers much more control than previous Google models or its competitors.
This article examined the nano-banana ability to generate and edit images. We will show these functions with Google to learn Platform and API Gemini In Python’s environment.
Let’s get it.
# Testing the nano-banana model
To follow this tutorial, you need to register to a Google account and log in to Google AI Studio. You will also have to get API key To utilize the APi Gemini interface, which requires a paid plan, because there is no free level available.
If you prefer to utilize the API of Python, make sure install Google Generative AI Library with the following command:
After configuring the account, examine how to utilize the nano-banana model.
First go to Google Ai Studio and choose Gemini-2.5-flash-image-preview A model that is a Nano-Banana model that we will utilize.

After the selected model, you can start a fresh chat to generate a picture from the poem. As Google suggests, the basic principle of obtaining the best results is Describe the scene, not just replace the keywords. This narrative approach, describing the image you imagine, usually gives excellent results.
In the AI Studio chat interface you will see a platform like the one below, in which you can enter a prompt.

We will utilize the following poem to generate a photorealistic image for our example.
A photorealistic portrait up close to Indonesian craftsman Batik, hands colored with wax, following a liquid motif on indigo fabric with a pen. He works at a wooden table in a windy porch; Convoluted textiles and VATS dyeing are blurring for it. Delayed wounds window lightweight sticks into the fabric, revealing petite wax lines and a grain of teak. Capped at 85 mm at f/2 for fragile separation and creamy bokeh. The overall mood is concentrated, touch and proud.
The generated image is shown below:

As you can see, the generated image is realistic and faithfully warns a given prompt. If you prefer Python’s implementation, you can utilize the following code to create an image:
from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO
from IPython.display import display
# Replace 'YOUR-API-KEY' with your actual API key
api_key = 'YOUR-API-KEY'
client = genai.Client(api_key=api_key)
prompt = "A photorealistic close-up portrait of an Indonesian batik artisan, hands stained with wax, tracing a flowing motif on indigo cloth with a canting pen. She works at a wooden table in a breezy veranda; folded textiles and dye vats blur behind her. Late-morning window light rakes across the fabric, revealing fine wax lines and the grain of the teak. Captured on an 85 mm at f/2 for gentle separation and creamy bokeh. The overall mood is focused, tactile, and proud."
response = client.models.generate_content(
model="gemini-2.5-flash-image-preview",
contents=prompt,
)
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('your_image.png')
display(image)
If you provide your API key and the desired prompt, the above Python code will generate the image.
We have seen that the Nano-Banana model can generate a photo report, but its strengths stretch further. As mentioned earlier, Nano-Banana is particularly powerful for editing images, which we will examine the next.
Let’s try the monitor edition of the paintings with the image that we have just generated. We will utilize the following prompt to slightly change the appearance of the craftsman:
Using the supplied image, gently place a few gaunt glasses for reading on the craft nose when it draws wax lines. Make sure the reflections look realistic, and the glasses naturally sit on her face without covering her eyes.
The resulting image is shown below:

The above image is identical to the first, but with glasses added to the craftsman’s face. This shows how Nano-Banana can edit a picture based on the descriptive Monik, maintaining overall consistency.
To do this with Python, you can provide your basic image and a fresh prompt using the following code:
from PIL import Image
# This code assumes 'client' has been configured from the previous step
base_image = Image.open('/path/to/your/photo.png')
edit_prompt = "Using the provided image, place a pair of thin reading glasses gently on the artisan's nose..."
response = client.models.generate_content(
model="gemini-2.5-flash-image-preview",
contents=[edit_prompt, base_image])
Then test the coherence of the character, generating a fresh scene in which the craftsman looks directly at the camera and smiles:
Generate a fresh and photorealistic image using the delivered image as a reference to identity: the same batik artisan, which now looks at a camera with a relaxed smile, sitting at the same wooden table. Average close -up, 85 mm appearance with a cushioned porch lightweight, background jars subtly blurred.
The image result is shown below.

We successfully changed the stage, maintaining the coherence of the character. To test a more drastic change, let’s utilize the following prompt to see how it performs nano-banana.
Create a product in the style of a product using the image supplied as an identity reference: the same craftsman depicting ready -made indigo battle fabric, arms stretching towards the camera. Pliable, even window lightweight, 50 mm appearance, neutral background mess.
The result is shown below.

The resulting picture shows a completely different scene, but maintains the same sign. This emphasizes the model’s ability to realistically produce different content from one reference image.
Then try the image style transfer. We will utilize the following prompt to change the photo report to the image of the watercolor.
Using the delivered image as a reference to identity, recreate the stage as a fragile watercolor on cool paper: loose indigo washing for a cloth, cushioned edges of bleeding on a floral motif, Blade Umbers for the table and background. Keep your pose by holding the material, a fragile smile and round glasses; Let the veranda go back in granulation of lightweight and perceptible paper texture.
The result is shown below.

The picture shows that the style has been transformed into a watercolor, while maintaining the subject and composition of the original.
Finally, we will try Fusion Image, where we will add an object from one image to another. In this example, I generated the image of a woman’s hat using nano-banana:

Using the image of the hat, we will now put it on the craft head with the following monitors:
Move the same woman and let it outside in open shade and place a straw hat from the product image on her head. Realistically align the crown and a roundabout to your head; Right over the right ear (left camera), tape tape drifts quietly with gravity. Utilize the cushioned lightweight of the sky as a key edge made of lightweight background. Keep a real straw and lace consistency, a natural skin tone and a reliable shadow from the edge above the forehead and the upper part of the glasses. Keep the Batik fabric and its hands unchanged. Keep the unchanged style of watercolor.
This process combines a photo of a hat with a basic image to generate a fresh image, with minimal changes in position and general style. At Python, utilize the following code:
from PIL import Image
# This code assumes 'client' has been configured from the first step
base_image = Image.open('/path/to/your/photo.png')
hat_image = Image.open('/path/to/your/hat.png')
fusion_prompt = "Move the same woman and pose outdoors in open shade and place the straw hat..."
response = client.models.generate_content(
model="gemini-2.5-flash-image-preview",
contents=[fusion_prompt, base_image, hat_image])
To get the best results, utilize a maximum of three input images. Using a larger number can reduce the output quality.
Try it for yourself and don’t be afraid to get ite, because you will often not receive the perfect picture at the first attempt.
# Wrapping
Gemini 2.5 Flash Image or Nano-Banana is the latest model of generating images and editing from Google. It has powerful possibilities compared to previous models for generating images. In this article, we examined how to utilize nano-banana to generate and edit images, emphasizing its features to maintain coherence and utilize stylistic changes.
I hope it was helpful!
Cornellius Yudha Wijaya He is a data assistant and data writer. Working full -time at Allianz Indonesia, he loves to share Python and data tips through social media and media writing. Cornellius writes on various AI topics and machine learning.
