title: How to remove beginning string in a base64 encoded image?
body: <p>So I got a code for encoding an image to a base64 one..</p>
  
  <pre><code>  function toDataUrl(url, callback) {
      var xhr = new XMLHttpRequest();
      xhr.responseType = 'blob';
      xhr.onload = function() {
        var reader = new FileReader();
        reader.onloadend = function() {
          callback(reader.result);
        }
        reader.readAsDataURL(xhr.response);
      };
      xhr.open('GET', url);
      xhr.send();
    }
  
    toDataUrl('img/no_image_icon.png', function(base64Img) {
      console.log(base64Img); // remove the data:image/png;base64, in the beginning
    });
  </code></pre>
  
  <p>This code works though I want to remove the <code>data:image/png;base64,</code> in the beginning of the generated <code>base64Img</code>. And also, how can I access it outside of the function? Like example</p>
  
  <pre><code>  toDataUrl('img/no_image_icon.png', function(base64Img) {
     var accessOutside = base64Img; // remove the data:image/png;base64, in the beginning
    });
  
    var newVariable = accessOutside;
  </code></pre>
  
  <p>Any help would be much appreciated.</p>