Generating Stacked Composite Images with Gemini AI
Stacked generation remains valid in multiple forms.
Approach A: Flexible Grid Strategy (General)
Useful when scene count varies widely and you want adaptive layouts.
- Compute
cols,rowsfrom scene count. - Allow layouts like
2x2,3x2,3x3,4x3. - Crop output back into scene images with Sharp.
Approach B: Deterministic Pipeline Grid Strategy
Useful when downstream splitting and indexing must stay predictable.
- Use fixed 3x3 composite batches.
- Generate with
gemini-3-pro-image-preview. - Use deterministic dimension maps per
videoTypeandimageSize. - Persist
grid_imageand splitslide_imageassets with stableasset_index.
Empty-cell Handling
Both approaches should explicitly specify filler content for unused cells to keep crop positions stable.
Splitting Notes
- Sharp-based cropping is valid for standalone flows.
- Sandbox/ImageMagick splitting is valid for memory-constrained worker pipelines.
- When reading split binary files from sandbox, use byte mode to avoid PNG corruption.
Cost Perspective
Stacked composites are often cheaper operationally than one request per scene, especially with larger scene counts.