Gemini image models reject arbitrary aspect ratios like 150:79 (computed via GCD from 1200×632 pixels). Replace GCD-based calculation with a snap-to-nearest approach using 7 standard ratios (1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16). Also set modalities to ["image", "text"] as required by some providers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>