-
Notifications
You must be signed in to change notification settings - Fork 26
/
resize_an_image.js
42 lines (38 loc) · 1.03 KB
/
resize_an_image.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
40
41
42
// Run this file as:
//
// env TRANSLOADIT_KEY=xxx TRANSLOADIT_SECRET=yyy node resize_an_image.js ./fixtures/berkley.jpg
//
// 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: {
resize: {
use: ':original',
robot: '/image/resize',
result: true,
imagemagick_stack: 'v2.0.7',
width: 75,
height: 75,
},
},
},
waitForCompletion: true,
}
const status = await transloadit.createAssembly(opts)
console.log('Your resized image:', status.results.resize[0].url)
} catch (err) {
console.error('createAssembly failed', err)
}
})()