JSON-Structured Image Decomposition: Generate Product Variants and A/B Test Images Without Design Software
What This Builds
A repeatable system for producing product image variations, A/B test assets, and multi-channel treatments from a single base photo. You extract a structured JSON "blueprint" of your product image, edit specific fields (color, material, background, finish), and re-apply the modified JSON to generate each variant. No Photoshop, no designer, no reshooting.
Prerequisites
- A Advanced account at gemini.google.com with image generation enabled
- At least one clean product photo (white or neutral background works best)
- A plain text editor (Notepad, TextEdit, or any code editor) to store and edit your JSON blueprints
- A folder system for organizing base images and output variants per SKU
The Concept
Think of your product image as a spreadsheet. Every visual element in the photo is a row: the product color, the background tone, the surface texture, the shadow direction, any props. Right now, that "spreadsheet" is invisible inside the pixels. This technique makes it visible.
You upload the image to Gemini and ask it to read the image and write out every element as structured JSON. Gemini returns something like "product_color": "navy blue" and "background": "seamless white" and "shadow": "soft drop, bottom-left". Each property is now a named, editable field.
To create a variant, you change one field. Swap "navy blue" to "forest green". Re-upload the original image with the modified JSON and the instruction to follow it. Gemini makes exactly that change and leaves everything else alone.
That last part is the key difference from standard AI image prompting. Free-text prompts drift: ask for a green version and the model might shift the camera angle, soften the shadow, or add a texture it invented. The JSON acts as a contract for every element in the image, not just the one you changed.
Build It Step by Step
Part 1: Extract Your Product's JSON Blueprint
Start with one hero image from your catalog. A clean white-background shot with consistent lighting works best for the first attempt.
Open gemini.google.com and start a new conversation. Upload your product image. Then paste this extraction prompt:
Analyze this product image and return a structured JSON object describing every visual element.
Include these fields:
- product_name
- product_color (be specific: hex-style name or Pantone-style descriptor)
- product_material
- product_finish (matte, gloss, satin, etc.)
- product_position (center, left-aligned, angled, etc.)
- background_color
- background_texture
- lighting_direction
- shadow_type (hard, soft, none, drop)
- shadow_position
- surface (what the product is resting on, if anything)
- props (any additional objects in the frame)
- image_aspect_ratio
Return only valid JSON. No explanation.
Copy the full JSON response into your text editor. Save it as [sku]-blueprint.json. This is your master template for this product.
If your catalog has product families (same item, multiple colorways), one extraction per family is enough. The other colorways will become edits of this blueprint.
Part 2: Create Your First Variant
Open the blueprint JSON you saved. Decide what you want to change. For a colorway variant, you'll only touch one or two fields. For an A/B background test, you'll touch the background fields.
Here is an example edit for a colorway variant:
Before:
{
"product_name": "Ceramic Pour-Over Coffee Dripper",
"product_color": "matte white",
"product_material": "ceramic",
"product_finish": "matte",
"product_position": "centered, slight 3/4 angle",
"background_color": "off-white",
"background_texture": "seamless paper",
"lighting_direction": "top-left soft box",
"shadow_type": "soft",
"shadow_position": "bottom-right",
"surface": "light oak wood surface",
"props": "none",
"image_aspect_ratio": "1:1"
}
After (sage green colorway):
{
"product_name": "Ceramic Pour-Over Coffee Dripper",
"product_color": "sage green",
"product_material": "ceramic",
"product_finish": "matte",
"product_position": "centered, slight 3/4 angle",
"background_color": "off-white",
"background_texture": "seamless paper",
"lighting_direction": "top-left soft box",
"shadow_type": "soft",
"shadow_position": "bottom-right",
"surface": "light oak wood surface",
"props": "none",
"image_aspect_ratio": "1:1"
}
Only product_color changed. Every other field stays identical.
Part 3: Apply the Modified Blueprint
Start a fresh Gemini conversation. Upload the original product image (the same base photo you used for extraction). Paste the modified JSON and add this instruction above it:
Modify this image based on the following JSON blueprint. Apply every field exactly as specified. Do not change any property that is not reflected in the JSON. Return only the edited image.
[paste your modified JSON here]
Gemini will generate the variant. Download it and save it with a descriptive filename: ceramic-dripper-sage-green-1x1.jpg.
If the output drifts (a field changed that you didn't edit), the fix is to make that field more explicit in your JSON rather than re-prompting in plain text. If the background shade shifted, add "background_hex": "#F5F0EB" to the JSON. Specificity suppresses drift.
Real Example: Generating Listing Images for a 6-Colorway Candle Line
Setup: You manage a DTC candle brand on Shopify and Amazon. You have one professional hero shot of your soy candle in cream. You need six colorway images (cream, terracotta, sage, charcoal, blush, cobalt) for each of three sizes (8 oz, 12 oz, 16 oz) — that's 18 listing images. A product photographer quoted $1,200 and a 2-week turnaround.
Input: Single cream candle hero shot (2000x2000, white background). One JSON blueprint extracted in 10 minutes.
Process:
- Extract blueprint from the cream base photo (10 minutes).
- Duplicate the blueprint file 5 times, one per additional colorway. Edit only
product_colorin each. - For size variants, add a
product_sizefield to the JSON:"product_size": "12 oz, taller and narrower than 8 oz". - Apply each modified blueprint to the original image in Gemini. Download and save each output.
- Do a quick visual QA pass: check that shadows, labels, and wax texture are consistent across all 18 images.
Output: 18 product images with consistent lighting, angle, background, and shadow. Label design and wax texture remain unchanged across all variants.
Time saved: Roughly 6-8 hours of manual editing or briefing a designer, plus the $1,200 shoot cost. First run takes about 90 minutes including QA. Subsequent product lines take 30-40 minutes once you have a blueprint template dialed in.
What to Do When It Breaks
The color changed but so did the texture or finish. Gemini sometimes interprets a color swap as permission to adjust the whole material. Add "product_finish": "matte" (or whatever the finish is) explicitly to the JSON even if it was already there. The redundancy reinforces the constraint.
The shadow disappeared or moved. The shadow fields are the most frequently dropped. Add "shadow_opacity": "medium" and "shadow_blur": "soft" to give Gemini more to anchor on.
The background picked up a color tint from the product. This happens with saturated colors like cobalt or red. Add "background_hex": "#FFFFFF" or "background_note": "pure white, no color cast" to the JSON.
The product shape changed slightly (more rounded, different proportions). This usually means the model is generating from scratch rather than editing. Try re-uploading the original image in the same message as the JSON. If it persists, add "product_shape": "cylindrical, straight sides" or a similar descriptor.
Gemini returns text instead of an image. Image generation is a separate capability from text generation. Check that you are in a Gemini session with image generation enabled, not a standard chat session. AI Studio (aistudio.google.com) is a free alternative if your quota is exhausted.
Variations
A/B background tests. Keep all product fields identical and only edit background_color and background_texture. This is the cleanest A/B test setup: the only variable between the two images is the background treatment.
Multi-channel crops. Add image_aspect_ratio to your edits: "1:1" for Amazon main image, "16:9" for Shopify hero banner, "4:5" for Instagram. Same product, optimized for each surface.
Lifestyle vs. studio variants. Swap surface from "seamless white paper" to "marble countertop" and props from "none" to "wooden coffee spoon, whole coffee beans scattered". The product stays identical; the context changes.
Seasonal treatments. Create a "seasonal JSON patch" file that you apply over any product's blueprint for holiday campaigns: swap background_color to "deep forest green", add props: "pine sprig, soft bokeh lights". Apply the patch to your top 20 SKUs in an afternoon.
Merging two images. Extract JSON from a reference image you want to borrow a property from (say, the lighting from a competitor's well-lit product shot). Copy only the lighting fields from that JSON into your product's blueprint. Re-apply. This lets you transfer a specific quality from one image to another without affecting anything else.
What to Do Next
Once you have a working blueprint for one product, scale the system to your full catalog. Create a folder called blueprints/ in your product assets directory. One JSON file per product family. Name them by SKU prefix so they're easy to find.
For seasonal or campaign-specific edits, build a library of "patch files" — small JSON fragments covering just the fields you want to swap. Apply patches to any base blueprint, combine them, and you have a modular system for generating campaign assets across your entire catalog in a single afternoon.
If you want to automate this further, n8n has a workflow template that connects a Google Sheet (list your SKUs and desired colorways) to Gemini via API. Each row triggers a generation job and saves the output to Google Drive. That setup requires some technical comfort, but the blueprint system you've built here is the input it needs.
Advanced guide for e-commerce coordinator professionals. These techniques use more sophisticated AI features that may require paid subscriptions.