Guest User

Untitled

a guest
Aug 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. fs.readFileSync('test.png', { encoding: 'base64' })
  2.  
  3. var gd = require('node-gd');
  4. var img = gd.openPng('test.png');
  5. var buff = Buffer.from(img.pngPtr(), 'binary');
  6. var b64 = buff.toString('base64');
  7.  
  8. console.log(b64);
  9.  
  10. /home/ubuntu/workspace/test.js:16
  11. var buff = Buffer.from(img.pngPtr(), 'binary');
  12. ^
  13.  
  14. TypeError: binary is not a function
  15. at Function.from (native)
  16. at Function.from (native)
  17. at Object.<anonymous> (/home/ubuntu/workspace/test.js:16:19)
  18. at Module._compile (module.js:409:26)
  19. at Object.Module._extensions..js (module.js:416:10)
  20. at Module.load (module.js:343:32)
  21. at Function.Module._load (module.js:300:12)
  22. at Function.Module.runMain (module.js:441:10)
  23. at startup (node.js:139:18)
  24. at node.js:968:3
  25.  
  26. new Buffer(pngFile.pngPtr(), 'binary')
Add Comment
Please, Sign In to add comment