Search Docs
Loading...
Skip to content

Bun

This guide walks you through integrating the CreativeEditor SDK (CE.SDK) Engine with the native Node.js bindings using Bun as the package manager and runtime. By the end of this guide, you’ll have a working script that loads a scene, modifies it, and exports it as an image using Bun’s fast runtime.

What’s CreativeEditor SDK?#

CreativeEditor SDK (CE.SDK) lets you integrate a customizable image and video editor into your web app. It includes filters, text overlays, and other media editing tools, and adapts easily to your use case.

CreativeEditor SDK is a commercial product. To use it, you need a valid license key. If you don’t have one yet, you can get a free trial or purchase a license.

Free Trial

Purchase License

Who Is This Guide For?#

This guide is for developers who:

  • Need to perform image, design, and video processing programmatically with native C++ performance using Bun.
  • Want to use CE.SDK’s native Node.js package for automation or backend processing with a fast, modern runtime.

What You’ll Achieve#

  • Install and configure CE.SDK Engine using the native bindings with Bun.
  • Load and manipulate design scenes programmatically.
  • Export designs as PNG images without requiring a UI.

Prerequisites#

Before getting started, ensure you have:

  • Bun installed (Download Bun).
  • A valid CE.SDK license key (Get a free trial).
  • A supported platform: macOS (Apple Silicon or Intel), Linux (x64, glibc 2.39 or later) or Windows (x64, Windows 10 or Windows Server 2016).
  • On Windows, install the GStreamer MSVC x86_64 runtime (1.24 or later) before you start. The package loads it at start, so it is necessary also for images. Windows renders on the CPU: device: 'gpu' gives an error and 'auto' uses the CPU.

Step 1: Set Up Your Project#

Initialize your project with Bun, selecting “Blank” for the template:

Terminal window
bun init my-cesdk-bun-project

Your project structure should look like this:

/my-cesdk-bun-project
├── node_modules
├── .gitignore
├── bun.lock
├── index.ts
├── package.json
├── README.md
└── tsconfig.json

Step 2: Install CE.SDK Native for Node.js Using Bun#

Navigate into your project folder and install the native package:

Terminal window
# Install the CE.SDK native Node.js package with Bun
bun add @cesdk/node-native@1.82.0

index.ts (TypeScript with Bun)#

Modify your index.ts file to initialize CE.SDK Engine and process a scene using Bun:

import { writeFile } from 'fs/promises';
import CreativeEngine from '@cesdk/node-native';
// Configuration for the engine
const config = {
license: 'YOUR_CESDK_LICENSE_KEY', // Replace with your CE.SDK license key
};
// Initialize CE.SDK Engine
CreativeEngine.init(config).then(async engine => {
console.log('CE.SDK Engine initialized');
try {
// Load a scene from a URL
await engine.scene.load(
'https://cdn.img.ly/assets/demo/v3/ly.img.template/templates/cesdk_instagram_photo_1.scene',
);
// Find the first page in the scene
const [page] = engine.block.findByType('page');
// Export the scene as a PNG image
const blob = await engine.block.export(page, {
mimeType: 'image/png',
});
const arrayBuffer = await blob.arrayBuffer();
// Save the exported image to the file system
await writeFile('./example-output.png', Buffer.from(arrayBuffer));
console.log('Export completed: example-output.png');
} catch (error) {
console.error('Error processing scene:', error);
} finally {
// Dispose of the engine to free resources
engine.dispose();
}
});

Step 3: Run the Script Using Bun#

Once everything is set up, run your script using:

Terminal window
bun run index.ts

This processes the scene and generates an image file named example-output.png in your project directory.

Troubleshooting & Common Errors#

❌ Error: Invalid license key

  • Verify that your license key is correct and not expired.

❌ Error: Cannot find module '@cesdk/node-native'

  • Ensure that @cesdk/node-native is installed correctly using bun add @cesdk/node-native@1.82.0.
  • Ensure you’re on a supported platform (macOS ARM/x64, Linux x64 with glibc 2.39 or later, or Windows x64). Windows ARM64, Alpine Linux (musl) and Linux ARM64 are not supported — use the WASM-based @cesdk/node package there.

❌ Error: SyntaxError: Unexpected token 'import'

  • Ensure your script is named index.ts for TypeScript support in Bun.

Next Steps#

Congratulations! You’ve successfully integrated CE.SDK Engine with the native Node.js bindings using Bun. Next, explore: