-
Notifications
You must be signed in to change notification settings - Fork 0
/
node-test.js
23 lines (17 loc) · 882 Bytes
/
node-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { SaImageUtils } = require('./lib/index')
//const imageUrl = 'https://media.npr.org/assets/img/2020/06/25/reflect---2020---nikkolas-sm--press-use-only_custom-e69861c02d0bdd02b7dd3358c6a4a097e0266a69-s1600-c85.jpg';
const imageUrl =
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/240px-JavaScript-logo.png'
process.on('uncaughtException', (error) => {
console.log('uncaughtException', error)
})
SaImageUtils.getRawImageFromUrl(imageUrl).then((rawImageInfo) => {
const { buffer, contentType } = rawImageInfo
console.debug('typeof buffer', typeof buffer)
//console.debug('buffer', buffer);
console.debug('buffer.length', buffer.length)
console.debug('contentType', contentType)
const base64 = SaImageUtils.rawImageToBase64(rawImageInfo)
console.debug('base64.length', base64.length)
//console.debug('base64', base64);
})