Skip to content

Instantly share code, notes, and snippets.

@ghiden
Created June 29, 2011 05:11
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghiden/1053196 to your computer and use it in GitHub Desktop.
Save ghiden/1053196 to your computer and use it in GitHub Desktop.
decode a base64 encoded image file with node.js
var fs = require('fs'),
decode64 = require('base64').decode;
var data = fs.readFileSync('./encode.png', 'base64');
var buffer = new Buffer(data, 'base64');
fs.writeFileSync('./decode.png', decode64(buffer), 'binary')
@EddieOne
Copy link

Cannot find module 'base64'

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! base64@2.1.0 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the base64@2.1.0 install script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment