# Gemini-3.1-flash-image-preview ignores ImageConfig aspect\_ratio and reshuffles layout on background edit

**URL:** <https://discuss.ai.google.dev/t/gemini-3-1-flash-image-preview-ignores-imageconfig-aspect-ratio-and-reshuffles-layout-on-background-edit/128031>\
**Category:** Gemini API\
**Tags:** api, models, bug, gemini-3\
**Created:** [March 2, 2026, 5:09pm UTC](https://discuss.ai.google.dev/t/gemini-3-1-flash-image-preview-ignores-imageconfig-aspect-ratio-and-reshuffles-layout-on-background-edit/128031 "2026-03-02T17:09:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamBox](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/jambox/32/99874_2.png) [@JamBox](https://discuss.ai.google.dev/u/JamBox)\
**Post date:** [March 2, 2026, 5:09pm UTC](https://discuss.ai.google.dev/t/gemini-3-1-flash-image-preview-ignores-imageconfig-aspect-ratio-and-reshuffles-layout-on-background-edit/128031/1 "2026-03-02T17:09:28Z")

</div>

\*\*Model:\*\* `gemini-3.1-flash-image-preview`

\*\*Issue 1: `ImageConfig(aspect_ratio=…)` is ignored\*\*

When passing `image_config=types.ImageConfig(aspect_ratio=“1:8”)` in `GenerateContentConfig`, the model ignores it and outputs its

own preferred size. A 1:8 tall image input consistently comes back resized to a different aspect ratio. It also usually doesn’t edit the image properly.

\*\*Issue 2: Background edit in chat mode reshuffles layout\*\*

Using chat mode (as recommended in the docs) to edit a generated image:

- Turn 1: Generate sprite sheet with 8 frames stacked vertically → returns e.g. 352×2928

- Turn 2: `“Change the white background to solid pure black #000000. Keep everything else exactly unchanged”` → returns 1408×768

(frames rearranged into a 4×2 grid, background not black)

The edit prompt is not respected — the model regenerates with a new layout instead of only changing the background color.

\*\*Workaround found:\*\* Square images (1:1) edit correctly. The reshuffling only occurs with non-square aspect ratios.

\*\*Repro (Python):\*\*

```python

from google import genai

from google.genai import types

from PIL import Image

client = genai.Client()

chat = client.chats.create(model=“gemini-3.1-flash-image-preview”)

img = Image.open(“tall\_sprite\_sheet.png”) # e.g. 96x768

response = chat.send\_message(

```
  \[img, "Redraw this as a fantasy knight. White background."\],

  config=types.GenerateContentConfig(

      response_modalities=\["IMAGE"\],

      image_config=types.ImageConfig(aspect_ratio="1:8"),

  ),

```

)

# Returns wrong aspect ratio

response2 = chat.send\_message(

```
  "Change the white background to solid pure black #000000. Keep everything else exactly unchanged"

```

)

# Returns different layout, background not black

SDK version: google-genai 1.65.0, Python 3.9

---

<div class="post-metadata">

**Author:** ![Darshat\_Shah](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/darshat_shah/32/32043_2.png) [@Darshat\_Shah](https://discuss.ai.google.dev/u/Darshat_Shah)\
**Post date:** [March 4, 2026, 11:05am UTC](https://discuss.ai.google.dev/t/gemini-3-1-flash-image-preview-ignores-imageconfig-aspect-ratio-and-reshuffles-layout-on-background-edit/128031/2 "2026-03-04T11:05:49Z")

</div>

Same issue here - it incorrectly returns its own preferred sizes. Only one that comes back reliably is 1:4 or 4:1 ratios at 512 resolution

---

<div class="post-metadata">

**Author:** ![system](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/system/32/1_2.png) [@system](https://discuss.ai.google.dev/u/system)\
**Post date:** [November 5, 2026, 6:35pm UTC](https://discuss.ai.google.dev/t/gemini-3-1-flash-image-preview-ignores-imageconfig-aspect-ratio-and-reshuffles-layout-on-background-edit/128031/3 "2026-11-05T18:35:48Z")

</div>

Closed on November 5, 2026, 6:35pm UTC

This thread was automatically closed 60 days after the last reply. If you are running into an issue, please create a new post.
