<script>
function xhr(url) {
  return new Promise(function(resolve, reject) {
      var request = new XMLHttpRequest();
      request.addEventListener(
        'error',
        function() { reject(new Error()); });
      request.addEventListener(
        'load',
        function(event) { resolve(request.response); });
      request.open('GET', url);
      request.send();
    });
}

function load_image(url, cross_origin) {
  return new Promise(function(resolve, reject) {
      var img = document.createElemen