**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