Multi-Image Comparison Prompts
Comparing two or more images: differences, similarities, changes over time.
Multi-Image Comparison Prompts is a free AI Prompt Engineering lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Prompt Engineering learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Multi-Image Prompts
Vision models can process multiple images in a single API call. This enables powerful comparison tasks:
- Before/after analysis (product photos, room renovations, medical imaging)
- Product variant comparison (color options, size comparisons)
- Quality comparison (selecting the best photo for a listing)
- Change detection (two versions of a document, two time-stamped images)
Multi-image prompts require careful structure so the model knows which image is which and what relationship to analyze.
Sending Multiple Images in One Call
The API accepts multiple images as a list of content items. Label each image explicitly:
import anthropic, base64
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
def compare_images(image_path_1, image_path_2, comparison_prompt):
def encode(path):
with open(path, 'rb') as f:
return base64.standard_b64encode(f.read()).decode('utf-8')
r = client.messages.create(
model='claude-opus-4-5', max_tokens=600,
messages=[{'role': 'user', 'content': [
{'type': 'text', 'text': 'IMAGE 1:'},
{'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': encode(image_path_1)}},
{'type': 'text', 'text': 'IMAGE 2:'},
{'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': encode(image_path_2)}},
{'type': 'text', 'text': comparison_prompt}
]}]
)
return r.content[0].text
print('Multi-image comparison function defined.')Two-Product Comparison Prompt
Comparing two product images for a consumer-facing application:
product_comparison_prompt = '''
Compare the two product images above (Image 1 and Image 2).
Analyze each of the following dimensions:
1. SIMILARITIES: What features, design elements, or characteristics do both products share?
2. DIFFERENCES: What are the key visual differences? Focus on:
- Color and finish
- Size and proportions (estimate if possible)
- Design style (minimalist, ornate, modern, traditional)
- Materials (if discernible)
- Quality indicators
3. QUALITY ASSESSMENT: Which image appears to show a higher-quality product, and why?
Rate each product 1-10 for apparent quality.
4. USE CASE: Based on appearance alone, which product seems better suited for:
a) Professional/office use
b) Home/casual use
Return your response in this format exactly.
'''
print(product_comparison_prompt)Before and After Comparison
Before/after prompts need to explicitly establish which image is which and what the transformation context is:
before_after_prompt = '''
You are looking at two images: a BEFORE image (Image 1) and an AFTER image (Image 2).
Analyze the transformation:
1. WHAT CHANGED: List all visible changes from Before to After
2. WHAT STAYED THE SAME: List elements that are unchanged
3. QUALITY IMPROVEMENT: Rate the improvement on a scale of 1-10 (1=no improvement, 10=dramatic improvement)
4. REMAINING ISSUES: What could still be improved that the transformation did not address?
Context: This is a [CONTEXT_PLACEHOLDER] before/after comparison.
Return JSON:
{
"changes": ["string"],
"unchanged": ["string"],
"improvement_score": 1-10,
"remaining_issues": ["string"],
"summary": "one sentence summary"
}
'''
# Use contexts: room renovation, product refurbishment, skin care treatment, document cleanup
print('Before/after prompt with JSON output defined.')Photo Quality Selection
Selecting the best photo from multiple options — useful for e-commerce, social media, and publishing workflows:
import anthropic, base64, json
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
def select_best_photo(image_paths, use_case='e-commerce product listing'):
def encode(path):
with open(path, 'rb') as f:
return base64.standard_b64encode(f.read()).decode('utf-8')
content = []
for i, path in enumerate(image_paths):
content.append({'type': 'text', 'text': f'IMAGE {i+1}:'})
content.append({'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': encode(path)}})
prompt = f'''
You have received {len(image_paths)} images. Select the best one for: {use_case}
Evaluate each on: lighting, composition, clarity, and suitability for the use case.
Return JSON: {{"best_image": 1-{len(image_paths)}, "score_breakdown": [{{"image_id": int, "score": 1-10, "reason": str}}]}}
'''
content.append({'type': 'text', 'text': prompt})
r = client.messages.create(model='claude-opus-4-5', max_tokens=300, messages=[{'role': 'user', 'content': content}])
return json.loads(r.content[0].text)
print('Photo selection function defined.')Change Detection Prompt
Detecting specific changes between two versions of the same image — useful for document versioning, UI design review, and monitoring:
change_detection_prompt = '''
Compare Image 1 (version A) with Image 2 (version B) of the same item.
Identify ALL changes, no matter how small.
For each change:
- Describe what changed
- Where in the image the change occurs (use quadrant: top-left, top-right, bottom-left, bottom-right, center)
- Classify the change: addition, removal, modification, movement
Return JSON:
{
"total_changes": int,
"changes": [
{
"description": str,
"location": str,
"type": "addition|removal|modification|movement"
}
],
"is_significant_change": true | false
}
If the images appear identical, return: {"total_changes": 0, "changes": [], "is_significant_change": false}
'''
print(change_detection_prompt)A/B Design Comparison
Comparing two design variants objectively — useful for UI/UX decisions and creative direction:
design_comparison_prompt = '''
You are an experienced UX designer reviewing two design variants (Image 1 = Design A, Image 2 = Design B).
Evaluate both designs on:
1. VISUAL HIERARCHY: Which design guides the eye more effectively? Why?
2. READABILITY: Which has better text legibility and information density?
3. BRAND CONSISTENCY: Which feels more professional and polished?
4. USABILITY: Which would be easier for a new user to navigate?
5. EMOTIONAL IMPACT: Which creates a stronger positive first impression?
For each dimension, declare a winner (A or B) and explain in one sentence.
Final verdict: Return JSON:
{
"winner": "A|B|tie",
"dimension_winners": {"visual_hierarchy": str, "readability": str, "brand": str, "usability": str, "emotional": str},
"winning_reasons": [str],
"recommendation": str
}
'''
print('Design comparison prompt defined.')Structured Similarity Scoring
For automated pipelines, produce numeric similarity scores between images:
similarity_prompt = '''
Compare these two images and provide a structured similarity analysis.
Return JSON:
{
"overall_similarity": 0.0-1.0,
"dimensions": {
"subject_match": 0.0-1.0,
"color_match": 0.0-1.0,
"composition_match": 0.0-1.0,
"style_match": 0.0-1.0
},
"key_differences": [str],
"are_same_item": true | false | "cannot_determine"
}
Scoring: 1.0 = identical, 0.0 = completely different.
'''
import json
def similarity_score(image_path_1, image_path_2):
result_text = compare_images(image_path_1, image_path_2, similarity_prompt)
return json.loads(result_text)
print('Similarity scoring function defined.')
print('Use case: duplicate detection, product matching, visual search.')Handling More Than Two Images
For three or more images, structure the prompt to handle the additional complexity:
def multi_image_prompt(n_images):
image_labels = ', '.join(f'Image {i+1}' for i in range(n_images))
return f'''
You have received {n_images} images: {image_labels}.
Rank all {n_images} images from best to worst for use as a product hero image.
For each image, provide:
- Rank (1=best)
- Score 1-10
- Key strengths
- Key weaknesses
Return JSON:
{{
"ranking": [
{{"rank": int, "image_id": int, "score": int, "strengths": [str], "weaknesses": [str]}}
],
"recommended_image": int
}}
'''
# Works for 3, 4, or 5 images
print(multi_image_prompt(3)[:300])Common Pitfalls in Multi-Image Prompts
Common mistakes when working with multiple images and how to avoid them:
- No image labels: Model may confuse which image is which — always label with IMAGE 1: text before each image
- No comparison frame: Asking to compare without specifying dimensions produces unfocused output — list exactly what to compare
- Missing context: Before/after prompts need the transformation context (room renovation, not just two room photos)
- Too many images: Quality degrades with 6+ images — process in batches of 2-4
- Forgetting JSON output: Prose comparison is hard to parse — always request structured JSON for pipelines
Temporal Image Sequence Analysis
When images represent a time sequence (weekly check-ins, construction progress, medical follow-ups), the comparison prompt should explicitly analyze progression over time:
temporal_prompt = '''
You are analyzing a sequence of images taken over time.
Image 1 = earliest, Image 2 = most recent.
Analyze the progression:
1. PROGRESS: What improvements or changes occurred from earliest to most recent?
2. REGRESSION: Any deterioration or negative changes?
3. RATE: Is the rate of change faster, slower, or as expected?
4. TRAJECTORY: Based on the trend, what is the likely state in the next period?
Return JSON:
{
"progress": [str],
"regression": [str],
"change_rate": "faster|on_track|slower|stalled",
"trajectory": str,
"next_period_prediction": str
}
'''
print("Temporal sequence analysis prompt defined.")
print("Use cases: fitness progress, construction tracking, medical imaging follow-up.")Quick Check
What is the most important structural element to include in a multi-image comparison prompt?
Multi-Image Comparison — Key Takeaways
Multi-image comparison prompts unlock powerful visual analysis capabilities:
- Always label images explicitly with text before each image in the content array
- Specify comparison dimensions — visual hierarchy, quality, similarity — rather than asking for generic comparison
- Before/after prompts need the transformation context (what kind of change happened)
- Use structured JSON output for pipelines — similarity scores, ranked lists, change detection
- Product comparison, photo quality selection, and A/B design review are high-value use cases
- Keep batches to 2-4 images maximum — quality degrades with more
- Change detection prompts should classify each change by type: addition, removal, modification, movement
Frequently asked questions
Is the “Multi-Image Comparison Prompts” lesson free?
Yes — the full text of “Multi-Image Comparison Prompts” is free to read here on the web, and the AI Prompt Engineering course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Prompt Engineering course, upgrade to CoddyKit PRO.
What will I learn in “Multi-Image Comparison Prompts”?
Comparing two or more images: differences, similarities, changes over time. You practise AI Prompt Engineering with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AI Prompt Engineering?
No prior experience is required. AI Prompt Engineering on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Multi-Image Comparison Prompts” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AI Prompt Engineering lesson?
Yes. Every AI Prompt Engineering lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Image Description and Captioning Prompts
- Visual Question Answering
- Multi-Image Comparison Prompts
- OCR and Document Analysis Prompts