function loadBinary(image, base64Url) { const type = imageType(image); if (type) { switch (type.mime) { case 'image/png': return loadPNG(image); case 'image/jpeg': return loadJPEG(image); case 'image/tiff': return loadTIFF(image); default: return loadGeneric(getBase64(type.mime)); } } return loadGeneric(getBase64('application/octet-stream')); function getBase64(type) { if (base64Url) { return base64Url; } else { return toBase64URL(image, type); } } }