var v=(R,s={width:1200,height:630,quality:1})=>new Promise((b,l)=>{let g=new FileReader;g.onload=h=>{let e=new Image;e.src=h.target?.result,e.onload=()=>{let t=s.width,c=s.height,r=document.createElement("canvas");r.width=t,r.height=c;let m=r.getContext("2d");m.imageSmoothingQuality="high";let a=e.width,n=e.height,f=a/n,d=t/c,o,i,u=0,w=0;f>d?(i=n,o=n*d,u=(a-o)/2):(o=a,i=a/d,w=(n-i)/2),m.drawImage(e,u,w,o,i,0,0,t,c);let I=r.toDataURL("image/jpeg",s.quality);b(I)},e.onerror=t=>l(new Error("Image loading error: "+t))},g.onerror=h=>l(new Error("FileReader error: "+h)),g.readAsDataURL(R)});export{v as a};
