Search Docs
Loading...
Skip to content

Multi Image Generation for Nuxt.js

Generate multiple image variants for a single data point.

Design Editor starter kit showing a professional design editing interface

10 mins
estimated time
Download
StackBlitz
GitHub

Prerequisites#

Before you begin, make sure you have the following:

  • Node.js v22+ and npm installed locally – Download Node.js
  • A supported browser – Chrome 114+, Edge 114+, Firefox 115+, Safari 15.6+
    See Browser Support for the full list.

Get Started#

Start fresh with a standalone Multi Image Generation project. This creates a complete, ready-to-run React application built with Vite. To add the editor to your Nuxt.js project, use the Existing Project tab.

Step 1: Clone the Repository#

Terminal
git clone https://github.com/imgly/starterkit-multi-image-generation-react-web.git
git clone https://github.com/imgly/starterkit-multi-image-generation-react-web.git

The src/ folder contains the application:

src/
├── app/ # Demo application
├── imgly/
│ ├── index.ts # Editor initialization function
│ ├── demo-assets.ts # Demo asset URLs
│ ├── asset-sources.ts # Asset source setup
│ ├── generation.ts # Design generation logic
│ ├── headless-engine.ts # Headless engine setup
│ ├── types.ts # TypeScript type definitions
│ ├── utils.ts # Utility functions
│ └── config/
│ ├── advanced-design-editor/
│ │ ├── plugin.ts # Main configuration plugin
│ │ ├── actions.ts # Export/import actions
│ │ ├── features.ts # Feature toggles
│ │ ├── i18n.ts # Translations
│ │ ├── settings.ts # Engine settings
│ │ ├── keyboard/ # Keyboard shortcuts
│ │ │ ├── keyboard.ts # Shortcut registration
│ │ │ └── catalogs/
│ │ │ └── us-ansi.ts # Key catalog
│ │ └── ui/ # UI customization
│ │ ├── index.ts # Combines UI customization exports
│ │ ├── canvas.ts # Canvas configuration
│ │ ├── components.ts # Custom component registration
│ │ ├── dock.ts # Dock layout configuration
│ │ ├── inspectorBar.ts # Inspector bar layout
│ │ ├── navigationBar.ts # Navigation bar layout
│ │ ├── panel.ts # Panel configuration
│ │ └── videoTimeline.ts # Timeline configuration
│ └── design-editor/ # Same structure as advanced-design-editor/
└── index.tsx # Application entry point

Step 2: Install Dependencies#

Install the required packages:

Terminal
cd starterkit-multi-image-generation-react-web
npm install
cd starterkit-multi-image-generation-react-web
npm install

Step 3: Download Assets#

CE.SDK requires engine assets (fonts, icons, UI elements) to function. For production, serve them as static files from your project’s public/ directory.

Terminal
curl -O https://cdn.img.ly/packages/imgly/cesdk-js/1.87.0-rc.3/imgly-assets.zip
unzip imgly-assets.zip -d public/
rm imgly-assets.zip
curl -O https://cdn.img.ly/packages/imgly/cesdk-js/1.87.0-rc.3/imgly-assets.zip
unzip imgly-assets.zip -d public/
rm imgly-assets.zip

Without further setup, the editor loads these assets from the IMG.LY CDN, which is for development only. To use the downloaded copy, set baseURL: '/assets' in the editor configuration in src/index.tsx. To add your license key, add one of the two license lines below to the same object, without the leading //. Option 1 puts the key in the code. Option 2 reads VITE_CESDK_LICENSE from a .env file, which you create as a copy of .env.example. Without a license key, the editor runs in evaluation mode and adds a watermark to exports.

src/index.tsx
const config = {
// ...
baseURL: '/assets',
// license: 'YOUR_CESDK_LICENSE_KEY' // Option 1: the key in the code
// license: import.meta.env.VITE_CESDK_LICENSE // Option 2: the key from .env
// ...
};

Step 4: Run the Development Server#

Terminal
npm run dev
npm run dev

Open http://localhost:5173 in your browser.

Using the Starterkit#

The imgly/ module provides a unified API for editor initialization, headless rendering, and batch generation. Import what you need from the single entry point:

app/components/MultiImageGenerationDesignEditor.client.vue
import {
// Editor Initialization
initMultiImageGenerationDesignEditor, // Adopter mode (light theme, standard editing)
initMultiImageGenerationAdvancedDesignEditor, // Creator mode (dark theme, full template design)
// Configuration Plugins (for direct use)
DesignEditorConfig,
AdvancedEditorConfig,
// Headless Engine
initMultiImageGenerationHeadlessEngine, // Initialize engine without UI
renderSceneToImage, // Load scene and export as image
// Generation Utilities
fillTemplate, // Fill template with data
generateAssets, // Batch generate multiple assets
applyRestaurantColors, // Apply brand colors to loaded scene
// Helper Utilities
hexToRgba, // Convert hex color to RGBA
replaceImageByName, // Replace image block by name
exportSceneAsImage // Export current scene as image
} from '~/imgly';

In the cloned starter kit, src/app/App.tsx and src/app/EditorModal/EditorModal.tsx import from the same imgly/ folder.

Editor Initialization#

Use initMultiImageGenerationDesignEditor or initMultiImageGenerationAdvancedDesignEditor to configure the editor with all necessary plugins and asset sources. The starter kit does this in its React file src/app/EditorModal/EditorModal.tsx, so adjust the import path to your imgly/ folder. SCENES is the kit’s src/app/scenes.json:

src/app/EditorModal/EditorModal.tsx
import CreativeEditor from '@cesdk/cesdk-js/react';
import {
initMultiImageGenerationDesignEditor,
initMultiImageGenerationAdvancedDesignEditor
} from '../../imgly';
import SCENES from '../scenes.json';
// `template`, `sceneString`, `selectedRestaurant` and `editorBaseConfig` are
// props of the EditorModal component
// Determine scene to load: saved scene or fresh template
const sceneToLoad = sceneString ?? SCENES[template.sceneKey];
<CreativeEditor
config={editorBaseConfig}
init={async (cesdk) => {
// Initialize appropriate editor configuration based on mode
if (selectedRestaurant) {
await initMultiImageGenerationDesignEditor(cesdk);
} else {
await initMultiImageGenerationAdvancedDesignEditor(cesdk);
}
// Load scene
await cesdk.load(sceneToLoad);
}}
/>

Generation Functions#

For batch image generation, use the headless engine with generation utilities:

Your generation script
import {
initMultiImageGenerationHeadlessEngine,
fillTemplate,
generateAssets,
exportSceneAsImage
} from '~/imgly';
import type { Template } from '~/imgly';
import { DEMO_ASSETS_BASE_URL } from '~/imgly/demo-assets';
// Scene strings by scene key, for example saved with engine.scene.saveToString()
const scenes: Record<string, string> = {
square: squareSceneString,
portrait: portraitSceneString,
landscape: landscapeSceneString
};
// Initialize headless engine (no UI)
const engine = await initMultiImageGenerationHeadlessEngine();
// Fill a single template with restaurant data
await fillTemplate(engine, scenes, 'square', restaurant);
const imageUrl = await exportSceneAsImage(engine);
// Or generate multiple assets at once
const templates: Template[] = [
{
label: 'Square',
sceneKey: 'square',
previewImagePath: `${DEMO_ASSETS_BASE_URL}/images/placeholder-1.png`,
outputFormat: 'image/png',
width: 240,
height: 240
},
{
label: 'Portrait',
sceneKey: 'portrait',
previewImagePath: `${DEMO_ASSETS_BASE_URL}/images/placeholder-2.png`,
outputFormat: 'image/png',
width: 200,
height: 280
},
{
label: 'Landscape',
sceneKey: 'landscape',
previewImagePath: `${DEMO_ASSETS_BASE_URL}/images/placeholder-3.png`,
outputFormat: 'image/png',
width: 280,
height: 200
}
];
await generateAssets(engine, scenes, templates, restaurant, (index, asset) => {
// Called for each generated asset
console.log(`Generated ${asset.label}:`, asset.src);
});
// Clean up when done
engine.dispose();

Set Up a Scene#

Replace the scene.create line from Get Started with one of these calls.

In the cloned starter kit, cesdk is available in the init callback in src/app/EditorModal/EditorModal.tsx.

CE.SDK offers multiple ways to load content into the editor. Choose the method that matches your use case:

app/components/MultiImageGenerationDesignEditor.client.vue
// Create a blank design canvas - starts with an empty design scene
await cesdk.actions.run('scene.create');
// Load from a template archive - restores a previously saved project
await cesdk.load('https://example.com/template.zip');
// Load from an image URL - creates a new scene with the image
await cesdk.createFromImage('https://example.com/image.jpg');
// Load from a scene file - restores a saved scene
await cesdk.load('https://example.com/scene.scene');

Key Capabilities#

The Multi Image Generation starter kit enables batch creation of on-brand design variations.

Batch Generation

Batch Generation

Generate multiple image variations from a single template with different data inputs.

Data-Driven Design

Data-Driven Design

Connect external data sources to dynamically populate design elements.

Template System

Template System

Create reusable templates with placeholders for text, images, and other content.

Multi-Format Export

Multi-Format Export

Export designs in multiple formats and sizes for different platforms.

Real-Time Preview

Real-Time Preview

Preview generated designs instantly before exporting.

Asset Libraries

Asset Libraries

Access built-in collections of templates, graphics, and fonts.



Troubleshooting#

Editor doesn’t load#

  • Check the editor size: Ensure the width and height of <CreativeEditor> give it a visible area
  • Verify the baseURL: Assets must be accessible from the CDN or your self-hosted location
  • Match the asset version: If the console says the assets are missing or from a different SDK version, check the installed @cesdk/cesdk-js version. Use the cesdk-js URL from Step 3 with that version number, and download imgly-assets.zip again. The cesdk-engine archive that the console names has no ui/ folder, so the editor does not start with it
  • Check console errors: Look for CORS or network errors in browser developer tools

Assets don’t appear#

  • Check network requests: Open DevTools Network tab and look for failed requests to cdn.img.ly
  • Self-host assets for production: See Serve Assets to host assets on your infrastructure

Watermark appears in production#


Next Steps#

  • Configuration – Complete list of initialization options
  • Serve Assets – Self-host engine assets for production
  • Actions – Build custom export and save workflows
  • Theming – Customize colors and appearance
  • Localization – Add translations and language support