title: Convert raw image to buffer
body: <p>There is apparently no easy way to stream images in Raspberry Pi. While there are many <em>hacks</em> available, in my Raspberry Pi Zero it has some trouble keeping a decent framerate.</p>
  
  <p>I suspect one of the main problems is that the <a href="http://thejackalofjavascript.com/rpi-live-streaming/" rel="nofollow noreferrer">1st Google solution</a> and most of them writes/reads to the SD for each image. I've got so far to read from the terminal an image without touching the SD:</p>
  
  <pre><code>const out = await exec(`fswebcam -r 640x480 -`);
  const img = out[0];
  console.log(img);
  </code></pre>
  
  <p>This gives me this on the terminal:</p>
  
  <pre><code> ����JFIF``��&gt;CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality
  ��      
  
   $.' ",#(7),01444'9=82&lt;.342��C          
  </code></pre>
  
  <p>And many more. Previously I was doing something similar with buffers:</p>
  
  <pre><code>const file = fs.readFileSync(temp);
  console.log(file.toString('base64'));
  ctx.socket.emit('frame', { image: true, buffer: file.toString('base64') });
  </code></pre>
  
  <p>Where <code>file</code> is a Buffer and <code>file.toString('base64')</code> is a string in the form of:</p>
  
  <pre><code>/9j/4AAQSkZJRgABAQEAYABgAAD//gA8Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2ODApLCBxdWFsaXR5ID0gMTAwCv ...
  </code></pre>
  
  <p>And this worked (but through the SD card). So my question is, what is the format of the first output in terminal? And how can I convert it to a Buffer or a String similar to the latter.</p>