Reads an image from url and convert it to base64
@param {string} url
@returns {Promise}
161318
function urlToBase64 (url) {
  return new Promise((resolve, reject) => {
    request.get(url, (err, response, body) => {
      err && reject(err)
      resolve(body.toString('base64'))
    })
  })
}
731024
function loadByDataUrl(url) {
      var results = dataUrlRegex.exec(url);
      var isBase64 = /base64/i.test(url);
      var data = isBase64 ? window.atob(results[2]) : results[2];

      return $q.when(angular.element(data)[0]);
    }
867388
function getImageSizeFromFile(file) {
	return new Promise((resolve, reject) => {
		const isDataUrl = file.match(/^data:.+?;base64,/);

		if (isDataUrl) {
			// NB should use sync version of `sizeOf()` for buffers
			try {
				const data = Buffer.from(file.slice(isDataUrl[0].length), 'base64');
				return resolve(sizeForFileName('', sizeOf(data)));
			} catch (err) {
				return reject(err);
			}
		}

		sizeOf(file, (err, size) => {
			if (err) {
				reject(err);
			} else {
				resolve(sizeForFileName(path.basename(file), size));
			}
		});
	});
}
856313
function decode(object) {
        if (defaults.decodeBase64 && object && object.content > '' &&
            object.encoding && object.encoding === 'base64') {
            object.content = b64decode(object.content)
        }
        return object
    }
1198111
function decode(cache, API_URL, str) {
  var cached = cache.get(str);
  if (typeof cached !== 'undefined') return cached;
  if (typeof str !== 'string') return null;

  var decoded = base64.decode(str).toString().replace(/\0/g, '');

  var out = validate(decoded) ?
    {href: unpack(decoded, API_URL)} :
    str;

  // cache the decoded value since this ends up being pretty expensive
  cache.set(str, out);

  return out;
}
670960
function parseUrl (url) {
  var urlRegExp = /(git:\/\/)|(http:\/\/)/;

  if(urlRegExp.test(url)) {
    return url.replace(urlRegExp, 'https://');
  }

  return url;
}
734290
function convertInlinePNG(source, dest) {
    if (!/^data\:image\/png/.test(source)) return Promise.reject(new Error('Source is not a PNG data-uri'));

    var base64data = source.split('data:image/png;base64,')[1];
    var buf = new Buffer(base64data, 'base64');

    return fs.writeFile(dest, buf)
    .then(function() {
        if (fs.existsSync(dest)) return;

        throw new Error('Error converting '+source+' into '+dest);
    });
}
832604
function( url, callback ) {

		// Node quick, not present on browser builds
		if (IS_NODE) {

			// Helper function
			var readChunk = function ( filename ) {
				// Read into buffer
				var file = fs.readFileSync(filename),
					u8 = new Uint8Array(file);
				// Return buffer
				return u8.buffer;
			}

			// Read by chunks
			if (url.substr(-5) === ".jbbp") {

				// Add by buffer
				var base = url.substr(0,url.length-5);
				this.addByBuffer( [
					readChunk(base + '.jbbp'),
					readChunk(base + '_b16.jbbp'),
					readChunk(base + '_b32.jbbp'),
					readChunk(base + '_b64.jbbp'),
				], callback );

			} else {

				// Add by buffer
				this.addByBuffer( readChunk(url), callback );

			}

			// Don't continue on browser builds
			return;

		}

		// Check for base dir
		var prefix = "";
		if (this.baseDir)
			prefix = this.baseDir + "/";

		// Check for sparse bundle
		var parts = url.split("?"), suffix = "", reqURL = [];
		if (parts.length > 1) suffix = "?"+parts[1];
		if (parts[0].substr(parts[0].length - 5).toLowerCase() === ".jbbp") {
			var base = prefix + parts[0].substr(0, parts[0].length - 5);
			reqURL = [
				base + '.jbbp' + suffix,
				base + '_b16.jbbp' + suffix,
				base + '_b32.jbbp' + suffix,
				base + '_b64.jbbp' + suffix
			];
		} else {
			// Assume .jbb if missing (TODO: not a good idea)
			var url = parts[0];
			if (url.substr(url.length-4) != ".jbb") url += ".jbb";
			reqURL = [ prefix + url + suffix ];
		}

		// Load bundle header and keep a callback
		// for the remainging loading operations
		var pendingBundle = {
			'callback': callback,
			'status': PBUND_REQUESTED,
			'buffer': undefined,
			'url': reqURL
		};

		// Keep this pending action
		this.queuedRequests.push( pendingBundle );

	}
580539
function(imageUrl, callback) {
        readers.getContentsFromUrl(imageUrl.toString(), function(err, data) {
            callback(err, err ? null : data);
        });

        return this;
    }
616654
function getUrl (url) {
  var opt = {
    url: url
  , timeout: 10000 // 10 seconds
  }
  ;
  return new Promise(function(resolve, reject){
    request(opt, function(err, res, body){
      if (err) { return reject(err); }
      resolve(body)
    });
  });
}
776667
function urlB64ToUint8Array(base64String) {
    const padding = '='.repeat((4 - base64String.length % 4) % 4);
    const base64 = (base64String + padding)
        .replace(/\-/g, '+')
        .replace(/_/g, '/');

    const rawData = self.atob(base64);
    const outputArray = new Uint8Array(rawData.length);

    for (let i = 0; i < rawData.length; ++i) {
        outputArray[i] = rawData.charCodeAt(i);
    }
    return outputArray;
}
91974
function toBase64URL(data) {
    if (typeof data === 'string') {
        data = new Buffer(data);
    }

    return data.toString('base64')
        .replace(/=+/g, '')     // remove '='s
        .replace(/\+/g, '-')    // '+' → '-'
        .replace(/\//g, '_');   // '/' → '_'
}
436775
function(url, img) {
        var svgImage = document.createElementNS(SVG_NS_URL, 'image');
        svgImage.setAttributeNS(XLINK_NS_URL, 'xlink:href', url);
        svgImage.setAttribute('x', 0);
        svgImage.setAttribute('y', 0);
        svgImage.setAttribute('width', img.width);
        svgImage.setAttribute('height', img.height);
        return svgImage;
      }
1131417
private Bitmap  checkForImageDataURL(String url)
   {
      if (!url.startsWith("data:"))
         return null;
      if (url.length() < 14)
         return null;

      int  comma = url.indexOf(',');
      if (comma == -1 || comma < 12)
         return null;
      if (!";base64".equals(url.substring(comma-7, comma)))
         return null;
      byte[]  imageData = Base64.decode(url.substring(comma+1), Base64.DEFAULT);
      return BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
   }
1259476
function jURL(url, base /* , encoding */) {
    if (base !== undefined && !(base instanceof jURL))
      base = new jURL(String(base));

    this._url = url;
    clear.call(this);

    var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
    // encoding = encoding || 'utf-8'

    parse.call(this, input, null, base);
  }
574906
def url_to_image(url, flag=cv2.IMREAD_COLOR):
    
    resp = urlopen(url)
    image = np.asarray(bytearray(resp.read()), dtype="uint8")
    image = cv2.imdecode(image, flag)
    return image
570018
function parseBase64Stream(req) {
  var passthrough = false;
  var accumulation = '';
  var stream = req.pipe(through(function(chunk, enc, callback) {
    if (!passthrough) {
      accumulation += chunk;
      var test = ';base64,';
      var index = accumulation.indexOf(test);
      if (index > -1) {
        passthrough = true;
        chunk = accumulation.substr(index + test.length);
      }
    }
    if (passthrough) {
      this.push(chunk);
    }
    callback();
  }))
    .pipe(base64.decode());
  return stream;
}