title: How to display a JPG image from a Node.js buffer (UInt8Array)
body: <p>I have a custom Node.JS addon that transfers a jpg capture to my application which is working great - if I write the buffer contents to disk, it's a proper jpg image, as expected. </p>
  
  <pre><code>var wstream = fs.createWriteStream(filename);
  wstream.write(getImageResult.imagebuffer);
  wstream.end();
  </code></pre>
  
  <p>I'm struggling to display that image as an img.src rather than saving it to disk, something like</p>
  
  <pre><code>var image = document.createElement('img');
  var b64encoded = btoa(String.fromCharCode.apply(null, getImageResult.imagebuffer));
  image.src = 'data:image/jpeg;base64,' + b64encoded;
  </code></pre>
  
  <p>The data in b64encoded after the conversion IS correct, as I tried it on <a href="http://codebeautify.org/base64-to-image-converter" rel="noreferrer">http://codebeautify.org/base64-to-image-converter</a> and the correct image does show up.  I must be missing something stupid.  Any help would be amazing!</p>
  
  <p>Thanks for the help!</p>