title: NodeJS: convert pngjs stream to base64
body: <p>I have a PNG object which I created using node-png and according the docs it's a &quot;<a href="https://www.npmjs.org/package/node-png" rel="nofollow noreferrer">readable and writable Stream</a>&quot;.</p>
  <p>I would like to convert the PNG object to base64 and send it to the client via socket.io where I'll place the string in an image src.</p>
  <p>I've tried many things but it seems that it's not trivial to convert a stream into a string.</p>
  <p>Note that the data is created inside Node and not from the file system.</p>
  <p>How can I achieve this?</p>