resize the image for preview and upload using html5 canvas