JSON-Structured Image Decomposition: Precise Edits to Course Graphics Without Starting Over
What This Builds
You upload a finished course diagram or illustration to Gemini, get back a structured JSON description of every visual element, modify only what needs to change, then re-apply that JSON to produce a corrected version. The surrounding graphic stays exactly as it was.
The payoff shows up on large course updates. When a client rebrands and changes their primary color from navy to teal, or when a compliance team updates a four-step process diagram to a five-step one, you no longer rebuild the graphic from scratch. You edit a handful of JSON fields and regenerate. Same visual language. Same layout. Same tone. Just the specific elements that changed.
Prerequisites
- Comfortable using Gemini for basic image generation (Level 3)
- Advanced subscription ($20/month) for best results — Sign up
- Existing course graphics you need to iterate on (PNG, JPG, or WEBP)
- A client brand guide or at least a known hex color palette
The Concept
Most AI image editors have a frustrating quirk: change one word in your prompt and the model adjusts things you didn't ask it to touch. You ask for a green box instead of blue, and suddenly the font changed, the icon moved, or a background element disappeared. For one-off image generation, that drift is annoying. For course design, where you need consistent visual language across 30 slides, it's a production problem.
The fix is to give the model a precise inventory of every element in the image before asking it to change anything. That inventory is a JSON object: every shape, color, label, icon, and background element gets named as a discrete field. When you modify only the field you want changed and leave the rest identical, the model treats the unmodified fields as constraints. It edits what you asked. Everything else holds.
Think of it like the difference between saying "please redecorate this room" versus handing someone a room inventory sheet with every piece of furniture listed, then circling the one chair you want reupholstered. The list tells them what not to touch.
Build It Step by Step
Part 1: Extract the JSON Blueprint
Open gemini.google.com and start a new conversation. Upload the course graphic you want to edit.
Then send this extraction prompt:
Analyze this image and return a structured JSON object that describes every visual element. For each element, include:
- name (descriptive label)
- type (shape, icon, text, arrow, background, border, container)
- color (hex code if visible, or closest descriptive value)
- position (top-left, center, bottom-right, etc.)
- content (text string if it's a text element; blank otherwise)
- style (flat, outlined, gradient, photographic, etc.)
Return only the JSON. No explanation.
Gemini will return something like:
{
"background": {
"type": "background",
"color": "#FFFFFF",
"style": "solid"
},
"step_1_box": {
"type": "container",
"color": "#003366",
"position": "left",
"style": "rounded rectangle"
},
"step_1_label": {
"type": "text",
"content": "Identify the Hazard",
"color": "#FFFFFF",
"position": "inside step_1_box"
},
"step_2_box": {
"type": "container",
"color": "#003366",
"position": "center-left",
"style": "rounded rectangle"
},
"connector_arrow_1": {
"type": "arrow",
"color": "#003366",
"position": "between step_1_box and step_2_box"
}
}
Copy the full JSON into a text editor. This is your blueprint.
Part 2: Make a Surgical Edit
Locate only the fields you want to change. Edit those field values. Leave everything else exactly as Gemini returned it.
Examples of targeted edits:
Rebrand primary color from navy to teal:
"step_1_box": { "color": "#008080" },
"step_2_box": { "color": "#008080" },
"connector_arrow_1": { "color": "#008080" }
Update a process step label:
"step_3_label": { "content": "Assess the Risk Level" }
Add a fifth step to a four-step process:
"step_5_box": {
"type": "container",
"color": "#008080",
"position": "far-right",
"style": "rounded rectangle"
},
"step_5_label": {
"type": "text",
"content": "Document and Report",
"color": "#FFFFFF",
"position": "inside step_5_box"
},
"connector_arrow_4": {
"type": "arrow",
"color": "#008080",
"position": "between step_4_box and step_5_box"
}
Keep every field you did not intend to change exactly as returned. Do not paraphrase or simplify the JSON.
Part 3: Re-apply and Verify
Start a fresh Gemini conversation. Upload the original image again. Then paste this prompt with your modified JSON:
Modify this image based on the following JSON prompt. Apply only the changes described by the modified fields. All other visual elements, layout, composition, fonts, spacing, and style should remain exactly as in the original image.
[paste your full modified JSON here]
Review the output against these checkpoints:
- Did only the intended elements change?
- Did the layout and proportions hold?
- Are fonts and spacing consistent with the original?
If something unexpected changed, find the JSON field that triggered it and either correct the value or remove the field entirely before regenerating.
Real Example: Rebranding a Safety Training Process Diagram
The situation: Your client, a mid-sized manufacturing company, just updated their brand guidelines. Their training division's four-step incident reporting process diagram needs to change from navy blue (#003366) to their new corporate teal (#00796B). The diagram appears in six separate Storyline modules. Rebuilding each from scratch in Canva would take 30-40 minutes per module.
Step 1: Extract the blueprint. Upload the original diagram to Gemini with the extraction prompt. The JSON comes back with 14 elements: four process boxes, four connector arrows, four step labels, one header text, and one background container.
Step 2: Edit the JSON. Find every element with "color": "#003366". Change each to "color": "#00796B". Four boxes, four arrows: eight field edits total. The text labels stay white. The background stays white. Nothing else changes.
Step 3: Regenerate. Upload the original image in a new Gemini conversation, paste the modified JSON, and send. Gemini produces a version where every navy element is now teal. Layout unchanged. Label text unchanged. Icon positions unchanged.
Step 4: Repeat across modules. Since all six modules use the same base diagram, the same modified JSON applies to each. Upload the original from each module, paste the same JSON, regenerate. Six updates in under 20 minutes instead of three to four hours.
Time saved: Approximately 3 hours across the rebrand project, not counting the fact that the consistency is exact across all six modules.
What to Do When It Breaks
The model changes elements you didn't modify — Remove any JSON key whose value might be implying visual relationships the model interprets broadly. A field like
"style": "corporate"may trigger broader stylistic changes. Replace evaluative descriptors with specific hex codes and geometric terms.The regenerated image looks nothing like the original — The extraction step may have produced a sparse JSON that didn't capture enough constraints. Re-run the extraction prompt and add this line: "Be exhaustive. Capture every visible element, including spacing, borders, shadows, and background fills." Then re-apply.
Gemini changes text content you didn't ask it to change — Add every text field explicitly to the JSON, even the ones you want unchanged. Gemini treats omitted fields as unconstrained. Specify
"content": "[exact original text]"for every label.The image quality drops on regeneration — This happens on the free tier when the source image is complex. Switch to Advanced or use AI Studio (aistudio.google.com) as a free alternative with the same underlying model.
A new element you added looks out of place stylistically — Extract the JSON from a second version of the diagram that has a similar element, copy only that element's JSON block, and merge it into your edited JSON. Let the reference image anchor the style of the new addition.
Variations
Simpler version: Use free-text editing prompts in Gemini without JSON. This works for single-element changes on simple graphics. Skip the extraction step and just say "change all navy blue to teal in this diagram." Reliability drops sharply as image complexity increases.
Extended version: Keep a JSON library for your recurring diagram types. A standard four-box process diagram JSON, a two-column comparison table JSON, a circular cycle diagram JSON. When you need a new graphic in that style, start from the template JSON and fill in content fields, rather than building from a blank Gemini prompt. Consistent visual language across an entire course catalog becomes a copy-paste operation.
Cross-module consistency check: Extract the JSON from two versions of the same diagram type from different modules. Compare the color and style fields side by side. Differences you find are inconsistencies that slipped through review. Fix and regenerate the outlier.
What to Do Next
- This week: Pick one existing diagram that needs a color update or label change and run the full JSON workflow on it. The goal is one successful end-to-end cycle so the process becomes familiar before you need to do it under deadline.
- This month: Build a JSON template library for your three or four most common diagram types. Store these in a shared doc with your team so consistency is systematic, not individual.
- Advanced: Combine this technique with a Claude Project loaded with your client's brand standards. Use Claude to validate that your modified JSON conforms to the brand guide before you send it to Gemini. The two tools working together become a lightweight visual QA layer.
Advanced guide for Instructional Designer professionals. These techniques use more sophisticated AI features that may require paid subscriptions.