GEMINI LABJP
FLASH — Gemini 3.5 Flash is now generally available, billed as the most intelligent model for agentic and coding tasksAGENTS — Managed Agents arrive in public preview, running autonomous agents in Google-hosted isolated Linux sandboxesWEBHOOK — Event-driven webhooks now replace polling for the Batch API and long-running operationsSEARCH — File Search goes multimodal, embedding and searching images via gemini-embedding-2SUNSET — gemini-3.1-flash-image-preview and gemini-3-pro-image-preview shut down on June 25ANTIGRAVITY — The Antigravity Agent managed agent (antigravity-preview-05-2026) is available in public previewFLASH — Gemini 3.5 Flash is now generally available, billed as the most intelligent model for agentic and coding tasksAGENTS — Managed Agents arrive in public preview, running autonomous agents in Google-hosted isolated Linux sandboxesWEBHOOK — Event-driven webhooks now replace polling for the Batch API and long-running operationsSEARCH — File Search goes multimodal, embedding and searching images via gemini-embedding-2SUNSET — gemini-3.1-flash-image-preview and gemini-3-pro-image-preview shut down on June 25ANTIGRAVITY — The Antigravity Agent managed agent (antigravity-preview-05-2026) is available in public preview
Articles/Advanced
Advanced/2026-06-13Advanced

Gemini's GA Image Models Won't Output Exact Device Resolutions — A Wallpaper Pipeline That Fixes Aspect Ratio and Safe Areas

After switching to the GA image models, your wallpapers no longer fit the screen. Here's how to crop one master image into every device resolution and cut your generation count to a fraction, with full Pillow code.

gemini86image-generation5wallpaperpillow2production116

Premium Article

Right after moving to the GA image models, I noticed the wallpapers I generated no longer fit the iPhone screen cleanly. I was sending the exact same prompts I had tuned during the preview era, yet some came back with bands of empty space top and bottom, and others had the subject clipped at the edges. The reason is simple: image models don't honor a pixel request like "give me 1206×2622 pixels." They return one of a fixed set of aspect ratios.

If you run a wallpaper app as an indie developer for any length of time, this mismatch between "what the model returns" and "what the device demands" is unavoidable. And since gemini-3.1-flash-image-preview and gemini-3-pro-image-preview are scheduled to shut down on 6/25, migrating to the GA models is exactly when this problem hits you head-on. Below is the "crop every device size from a single master" design I use in my own wallpaper generation pipeline, with working code.

Why pixel requests don't work

When you ask an image model for "1206×2622px output" — whether in the prompt or a parameter — what comes back is rounded to one of the aspect ratios the model supports (1:1, 3:4, 4:3, 9:16, 16:9, and so on). This is true on both the GA and the preview models. The model understands ratios, but it will not produce absolute pixel dimensions tailored to your device.

A wallpaper app, on the other hand, needs exact device pixels. Line up the major portrait devices and the required resolutions cluster like this:

  • iPhone Air: 1260 × 2736 px (aspect ratio ~0.46)
  • iPhone 17 Pro: 1206 × 2622 px (~0.46)
  • iPhone 16/17 Pro Max: 1320 × 2868 px (~0.46)
  • Pixel 9 Pro class Android: 1280 × 2856 px (~0.448)
  • Common Android xxxhdpi portrait wallpaper: 1440 × 3200 px (~0.45)

Notice that every ratio sits between 0.45 and 0.46. That is taller than 9:16 (= 0.5625). In other words, an image generated at 9:16 is "wider" than what the device wants, so trimming the horizontal edges covers every model. That points to the most robust approach: generate at 9:16, then resolve the exact pixels in post-processing.

The starting decision — crop every device from one master

This is the most important judgment in this article. Rather than calling the generation API once per device, I recommend generating a single, sufficiently large master image and cropping/resizing it down to each device resolution.

There are two reasons. The first is cost. Image generation is billed per image. Say it's $0.04 per image: generating four device variants separately means four charges per design. Cropping from one master means a single charge, cutting the generation count to a fraction of the device count — in this case 1/4. If you're preparing 1,000 wallpaper designs, that's 4,000 calls dropping to 1,000.

The second is consistency. Generate per device and the same prompt drifts slightly in composition and color each time. Derive everything from one master and every device gets exactly the same artwork.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
If your GA image-model output never matched device resolutions, you'll walk away with code that crops one master into every device size precisely
You'll be able to switch a per-device pipeline that ran up API costs into one that cuts generations to a fraction of the device count
With safe-area-aware prompts and cropping, you can ship wallpapers at scale without the subject getting clipped
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Advanced2026-06-14
Trusting Gemini Structured Output in Production — Schema Design, Double Validation, and Bounded Retries
Gemini's structured output guarantees parseable JSON, not correct values. Notes on schema design with @google/genai, why propertyOrdering matters, a Zod double-validation layer, handling MAX_TOKENS truncation, and a bounded-retry extraction pipeline.
Advanced2026-06-14
Switching Image Models Quietly Degrades Quality — A Gate That Catches It Without Manual Review
When you move image generation from preview to GA models, the API keeps returning 200 and quality slips silently. This is the three-layer gate I built to detect that drift without staring at every image: deterministic property checks, multimodal embedding similarity, and a Gemini judge, wired together in Python with thresholds and a cutover procedure.
Advanced2026-04-27
Self-Healing Architecture for Gemini Computer Use — Production Patterns That Keep Browser Automation Alive Beyond Day Three
Gemini Computer Use looks magical in demos but breaks daily in production: vanishing elements, surprise modals, network jitter, off-by-four-pixel clicks. This guide builds a five-layer self-healing architecture in Python that classifies failures and recovers them automatically, with working code you can drop into your agent loop today.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →