Search
Loading...
Skip to content

Using Default Assets

Load all asset sources from IMG.LY’s CDN to populate your CE.SDK engine with shapes, stickers, filters, effects, fonts, images, and other media for server-side rendering.

5 mins
estimated time
Download
StackBlitz
GitHub

CE.SDK provides built-in asset sources for shapes, stickers, filters, effects, fonts, and sample media. This guide demonstrates loading all available asset sources from IMG.LY’s CDN 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?#

IMG.LY provides two categories of asset sources hosted on the IMG.LY CDN for development and prototyping:

Default Assets are core editor components:

Source IDDescription
ly.img.stickerEmojis, emoticons, decorations
ly.img.vectorpathShapes: stars, arrows, polygons
ly.img.colors.defaultPaletteDefault color palette
ly.img.filter.lutLUT-based color filters
ly.img.filter.duotoneDuotone color effects
ly.img.effectVisual effects
ly.img.blurBlur effects
ly.img.typefaceFont families
ly.img.crop.presetsCrop presets
ly.img.page.presetsPage size presets
ly.img.page.presets.videoVideo page presets

Demo Assets are sample content for development:

Source IDDescription
ly.img.imageSample images
ly.img.videoSample videos
ly.img.audioSample audio tracks
ly.img.templateDesign templates
ly.img.video.templateVideo templates
ly.img.textComponentsText component presets

Loading Assets from URL#

Use addLocalAssetSourceFromJSONURI() to load an asset source directly from a JSON URL:

const baseURL = `https://cdn.img.ly/packages/imgly/cesdk-node/${CreativeEngine.version}/assets/v4/`;
await engine.asset.addLocalAssetSourceFromJSONURI(
`${baseURL}ly.img.vectorpath/content.json`
);

Initialize the Engine#

Create the Creative Engine instance:

const engine = await CreativeEngine.init({
// license: process.env.CESDK_LICENSE
});

Versioned CDN URLs#

Use the SDK version to construct versioned CDN URLs. This ensures assets are compatible with your SDK version. For production deployments, see the Serve Assets guide to self-host assets.

// Versioned CDN URLs using the SDK package (recommended)
// For production, self-host these assets - see the Serve Assets guide
const PACKAGE_BASE = `https://cdn.img.ly/packages/imgly/cesdk-node/${CreativeEngine.version}/assets`;
const DEFAULT_ASSETS_URL = `${PACKAGE_BASE}/v4/`;
const DEMO_ASSETS_URL = `${PACKAGE_BASE}/demo/v2/`;

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 PNG
const 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 = `https://cdn.img.ly/packages/imgly/cesdk-node/${CreativeEngine.version}/assets/v4/`;
// Load only star and arrow shapes
await engine.asset.addLocalAssetSourceFromJSONURI(
`${baseURL}ly.img.vectorpath/content.json`,
{ matcher: ['*star*', '*arrow*'] }
);
// Load only emoji stickers
await 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#

MethodDescription
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:

ParameterTypeDescription
contentURIstringFull URL to the content.json file
options.matcherstring[]Optional wildcard patterns to filter assets

Returns: Promise<string> — The asset source ID from the JSON

Next Steps#