Redraw the image using canvas and generate a base64 string with toDataURL. Keep the canvas dimension within 160*160 to ensure the base64 string stays under 80KB.
Source code address: https://github.com/rongcloud/rongcloud-web-im-upload/tree/master/upload/init.js