Automatic Social Media Image Generation from Product Cards

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Automatic Social Media Image Generation from Product Cards
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Implementing Automatic Social Media Image Generation from Product Cards

Creating graphics manually for each product and each social network is expensive and slow. Automation: take data from a product card (photo, name, price, brand) and generate ready-made banners in required formats—for Telegram, VK, Instagram, Stories.

Two Generation Approaches

Template-based approach (fast, predictable) — overlay product data onto pre-prepared design templates. Use Pillow (Python) or Sharp (Node.js).

AI generation (creative, variable) — generate backgrounds or entire images via Stable Diffusion, Midjourney API, DALL-E with subsequent text overlay.

For most stores, the first approach—template-based—provides branded results without surprises.

Pillow Implementation

from PIL import Image, ImageDraw, ImageFont
import httpx
from io import BytesIO

class ProductBannerGenerator:
    TEMPLATES = {
        'feed':    (1080, 1080),   # Instagram/VK post
        'story':   (1080, 1920),   # Instagram/VK Stories
        'telegram': (1280, 640),   # Telegram preview
    }

    def generate(self, product: dict, format: str = 'feed') -> bytes:
        width, height = self.TEMPLATES[format]

        # Create canvas
        canvas = Image.new('RGB', (width, height), color='#FFFFFF')
        draw   = ImageDraw.Draw(canvas)

        # Load and place product photo
        if product.get('image_url'):
            product_img = self._load_image(product['image_url'])
            product_img = self._fit_image(product_img, (width, int(height * 0.65)))
            canvas.paste(product_img, (0, 0))

        # Gradient underlay for text
        gradient = self._create_gradient((width, int(height * 0.4)), '#000000', alpha_start=0, alpha_end=180)
        canvas.paste(gradient, (0, int(height * 0.6)), mask=gradient)

        # Fonts
        font_title = ImageFont.truetype('fonts/Inter-Bold.ttf', size=52)
        font_price = ImageFont.truetype('fonts/Inter-ExtraBold.ttf', size=72)
        font_small = ImageFont.truetype('fonts/Inter-Regular.ttf', size=36)

        # Text
        y_offset = int(height * 0.68)
        draw.text((60, y_offset), product['name'], font=font_title, fill='white')
        draw.text((60, y_offset + 70), f"{product['price']:,.0f} USD", font=font_price, fill='#FFD700')

        # Brand logo
        logo = Image.open('assets/logo.png').resize((200, 60))
        canvas.paste(logo, (width - 220, 20), mask=logo)

        # Convert to bytes
        output = BytesIO()
        canvas.save(output, 'JPEG', quality=90)
        return output.getvalue()

    def _load_image(self, url: str) -> Image.Image:
        resp = httpx.get(url, timeout=15)
        return Image.open(BytesIO(resp.content)).convert('RGBA')

Generation via Replicate API (Stable Diffusion)

import replicate

def generate_ai_background(product_name: str, category: str) -> str:
    output = replicate.run(
        "stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf",
        input={
            "prompt": f"minimalist product photography background for {category}, "
                      f"clean white studio, soft shadows, high-end commercial photo",
            "negative_prompt": "text, watermark, ugly, blurry",
            "width": 1080,
            "height": 1080,
        }
    )
    return output[0]  # URL of generated image

Formats and Sizes

Platform Post Stories
Instagram 1080×1080, 1080×1350 1080×1920
VK 1080×1080 1080×1920
Telegram channel 1280×640

The system generates all variants in one call.

Timeline

Banner generator on templates with 3–5 formats: 4–6 business days. With AI background generation via Replicate: +2–3 days.