Register CE.SDK’s default asset sources from your self-hosted asset library to populate the engine with shapes, stickers, filters, effects, fonts, images, and other media for server-side rendering.
CE.SDK provides built-in asset sources for shapes, stickers, filters, effects, fonts, and sample media. This guide demonstrates registering all available asset sources from your self-hosted asset library and applying them to create a scene with a star shape, a sticker, and an image, then exporting to PNG.
What Are Default and Demo Assets?#
CE.SDK ships two categories of asset sources you self-host and register with the engine:
Default Assets are core editor components:
| Source ID | Description |
|---|---|
ly.img.sticker |
Emojis, emoticons, decorations |
ly.img.vector.shape |
Shapes: stars, arrows, polygons |
ly.img.color.palette |
Default color palette |
ly.img.filter.lut |
LUT-based color filters |
ly.img.filter.duotone |
Duotone color effects |
ly.img.effect |
Visual effects |
ly.img.blur |
Blur effects |
ly.img.typeface |
Font families |
ly.img.crop.presets |
Crop presets |
ly.img.page.presets |
Page size presets |
ly.img.page.presets.video |
Video page presets |
Demo Assets are sample content for development:
| Source ID | Description |
|---|---|
ly.img.image |
Sample images |
ly.img.video |
Sample videos |
ly.img.audio |
Sample audio tracks |
ly.img.template |
Design templates |
ly.img.video.template |
Video templates |
ly.img.text.components |
Text component presets |
Loading Assets from URL#
Use addLocalAssetSourceFromJSONURI() to register an asset source from its content.json. @cesdk/node is offline-first: it resolves assets relative to the engine’s baseURL (your self-hosted assets), so no IMG.LY CDN is used at runtime.
const baseURL = engine.getBaseURL();await engine.asset.addLocalAssetSourceFromJSONURI( `${baseURL}ly.img.vector.shape/content.json`);Initialize the Engine#
Create the Creative Engine instance:
const engine = await CreativeEngine.init({ baseURL: process.env.IMGLY_LOCAL_ASSETS_URL // license: process.env.CESDK_LICENSE});Point at Your Self-Hosted Assets#
@cesdk/node resolves asset sources relative to the engine’s baseURL. Self-host the asset library (extract imgly-assets.zip) and set baseURL on init — there is no IMG.LY CDN in the production path. See the Serve Assets guide for the download and setup steps.
// Resolve asset sources from the engine's self-hosted baseURL.const DEFAULT_ASSETS_URL = engine.getBaseURL();const DEMO_ASSETS_URL = engine.getBaseURL();Loading Default Asset Sources#
Load a default asset source from the CDN. Repeat this pattern for each source you need:
// Load default asset sources (core editor components)await engine.asset.addLocalAssetSourceFromJSONURI( `${DEFAULT_ASSETS_URL}ly.img.sticker/content.json`);Loading Demo Asset Sources#
Load a demo asset source from the CDN. Repeat this pattern for each source you need:
// Load demo asset sources (sample content for testing)await engine.asset.addLocalAssetSourceFromJSONURI( `${DEMO_ASSETS_URL}ly.img.image/content.json`);Exporting the Scene#
Export the scene as a PNG file:
// Export the scene as PNGconst pngBlob = await engine.block.export(page, { mimeType: 'image/png' });const pngBuffer = Buffer.from(await pngBlob.arrayBuffer());await writeFile('output/scene.png', pngBuffer);
console.log('Exported scene to output/scene.png');Cleanup#
Always dispose of the engine when finished:
engine.dispose();Filtering Assets with Matcher#
Use the matcher option to load only specific assets from a source:
const baseURL = engine.getBaseURL();
// Load only star and arrow shapesawait engine.asset.addLocalAssetSourceFromJSONURI( `${baseURL}ly.img.vector.shape/content.json`, { matcher: ['*star*', '*arrow*'] });
// Load only emoji stickersawait engine.asset.addLocalAssetSourceFromJSONURI( `${baseURL}ly.img.sticker/content.json`, { matcher: ['*emoji*'] });An asset is included if it matches ANY pattern in the array. Patterns support * wildcards.
API Reference#
| Method | Description |
|---|---|
engine.asset.addLocalAssetSourceFromJSONURI(contentURI, options?) |
Load an asset source from a JSON URL |
engine.asset.fetchAsset(sourceId, assetId) |
Fetch a specific asset by ID |
engine.asset.apply(sourceId, asset) |
Apply an asset to create a block |
Parameters for addLocalAssetSourceFromJSONURI:
| Parameter | Type | Description |
|---|---|---|
contentURI |
string |
Full URL to the content.json file |
options.matcher |
string[] |
Optional wildcard patterns to filter assets |
Returns: Promise<string> — The asset source ID from the JSON
Next Steps#
- Serve Assets — Self-host assets for production deployments
- Import From Remote Source — Load assets from external URLs