BASE64 img onto Canvas (HTML JavaScript) What is wrong with this piece code please? my image wont display...
async function reduce_image_size(Base64str,MaxWidth=300,MaxHeight=300) { alert('Reduce_Image'); <!-- resized base64= await new Promise((resolve)=> { //--> alert('here0'); var canvas=document.createElement('canvas'); var context = canvas.getContext("2d"); img=new image() alert("here1"); img.src=Base64str; width=img.width; height=img.height; alert("here"); if (width>height) { if (width>MaxWidth) { height=MaxWidth/width; width=MaxWidth;} } else { if (height>MaxHeight) { width=MaxHeight/height; height=MaxHeight; } } img.onload=() => { canvas.width=width; canvas.height=height; resolve(canvas.toDataUrl) } <!-- }) ///--> return Base64str; }