forked from transloadit/node-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrasterize_svg_to_png.js
39 lines (35 loc) · 972 Bytes
/
rasterize_svg_to_png.js
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
34
35
36
37
38
39
// Run this file as:
//
// env TRANSLOADIT_KEY=xxx TRANSLOADIT_SECRET=yyy node rasterize_svg_to_png.js ./fixtures/circle.svg
//
// You'll likely just want to `require('transloadit')`, but we're requiring the local
// variant here for easier testing:
const Transloadit = require('../src/Transloadit')
const transloadit = new Transloadit({
authKey : process.env.TRANSLOADIT_KEY,
authSecret: process.env.TRANSLOADIT_SECRET,
})
const filePath = process.argv[2];
(async () => {
try {
const opts = {
files: {
file1: filePath,
},
params: {
steps: {
png: {
use : ':original',
robot : '/image/resize',
format: 'png',
},
},
},
waitForCompletion: true,
}
const status = await transloadit.createAssembly(opts)
console.log('Your PNG file:', status.results.png[0].url)
} catch (err) {
console.error('createAssembly failed', err)
}
})()