const e=(e,t={width:1200,height:630,quality:1})=>new Promise((n,r)=>{let i=new FileReader;i.onload=e=>{let i=new Image;i.src=e.target?.result,i.onload=()=>{let e=t.width,r=t.height,a=document.createElement(`canvas`);a.width=e,a.height=r;let o=a.getContext(`2d`);o.imageSmoothingQuality=`high`;let s=i.width,c=i.height,l=s/c,u=e/r,d,f,p=0,m=0;l>u?(f=c,d=c*u,p=(s-d)/2):(d=s,f=s/u,m=(c-f)/2),o.drawImage(i,p,m,d,f,0,0,e,r),n(a.toDataURL(`image/jpeg`,t.quality))},i.onerror=e=>r(Error(`Image loading error: `+e))},i.onerror=e=>r(Error(`FileReader error: `+e)),i.readAsDataURL(e)});export{e as t};
//# sourceMappingURL=resize-image-C2igYbk2.mjs.map