You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
520 B

function s(r){const o=r.split(","),a=o[0].match(/:(.*?);/)[1],t=window.atob(o[1]);let n=t.length;const e=new Uint8Array(n);for(;n--;)e[n]=t.charCodeAt(n);return new Blob([e],{type:a})}function l(r,o){return new Promise((c,a)=>{let t=document.createElement("CANVAS");const n=t.getContext("2d"),e=new Image;e.crossOrigin="",e.onload=function(){if(!t||!n)return a();t.height=e.height,t.width=e.width,n.drawImage(e,0,0);const i=t.toDataURL(o||"image/png");t=null,c(i)},e.src=r})}export{s as dataURLtoBlob,l as urlToBase64};