-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (27 loc) · 1010 Bytes
/
index.js
File metadata and controls
33 lines (27 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import 'dotenv/config';
import fs from 'fs/promises';
import CreativeEngine from '@cesdk/node';
// Configuration for the engine
const config = {
license: process.env.LICENSE_KEY,
userId: 'guides-user',
baseURL: 'https://cdn.img.ly/packages/imgly/cesdk-node/1.60.0/assets'
};
CreativeEngine.init(config).then(async (engine) => {
console.log('CE.SDK Engine initialized');
try {
await engine.addDefaultAssetSources();
await engine.scene.loadFromURL(
'https://cdn.img.ly/assets/demo/v1/ly.img.template/templates/cesdk_instagram_photo_1.scene'
);
const [page] = engine.block.findByType('page');
const blob = await engine.block.export(page, { mimeType: 'image/png' });
const arrayBuffer = await blob.arrayBuffer();
await fs.writeFile('./assets/example-output.png', Buffer.from(arrayBuffer));
console.log('Export completed: example-output.png');
} catch (error) {
console.error('Error processing scene:', error);
} finally {
engine.dispose();
}
});