This article presents an open-source AI workflow for automatically generating brand-consistent advertising materials. The system leverages advanced AI models to create professional ads by replacing products in existing advertisements while maintaining the original style and composition.
The core functionality enables users to upload a product photo and a reference advertisement, then automatically replace the product in the reference ad with the user’s product while preserving all other visual elements and styling.
Practical Application:
The workflow begins with a form submission node that accepts both product images and reference advertisements. These files are then processed through conversion nodes to transform them into Base64-encoded strings for API compatibility.
The system employs a sophisticated meta-prompting strategy utilizing multiple Gemini AI models. The first Gemini model analyzes the input images to generate optimized prompts, while the second model uses these prompts to create the final output. This two-stage approach ensures superior image generation quality.
Critical Prompt Configuration:
Expert-Level Prompt Engineering Template:
You are an expert in image analysis and prompt engineering. I need your help to write a perfect prompt for generating/editing an advertisement featuring [Your Product Name]. Attached are two images:
1. Product image of [Your Product]
2. Reference advertisement from [Competitor Brand]
Analyze these images and create a detailed prompt for cloning the competitor's ad style while featuring our product. Maintain identical visual composition, lighting, and atmosphere, but replace all competitor branding with our product packaging.
Key considerations:
- Complete replacement of competitor branding elements (logos, text, labels)
- Preservation of original ad layout and visual hierarchy
- Integration of product specifications, care labels, and packaging details
- Consistent brand identity throughout the composition
The final output should be a professional advertisement promoting [Your Product Name] while maintaining the visual quality and style of the reference ad. Ensure all text elements are updated to reflect our brand identity.
Note: This template should be customized based on specific product characteristics and chosen AI models for optimal results.
Primary Analysis Node (Gemini 2.5 Pro):
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent{ "contents": [{ "parts": [ { "text": {{ JSON.stringify($json.prompt) }} }, { "inline_data": { "mime_type": "image/png", "data": "{{ $('convert_your_file').item.json.Your_File }}" } }, { "inline_data": { "mime_type": "image/jpeg", "data": "{{ $('convert_clone_file').item.json.Clone_File }}" } } ] }]}
Image Generation Node (Gemini 2.5 Flash):
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContentThe workflow includes content validation checks and automated file conversion to JPG format, with optional integration to Google Drive for asset management.