How to convert the downloaded img in a web page to base64 data

The

page cannot request a picture again after loading a picture, but the picture needs to be read out by script. When canvas changes to base64, you still need to set up the picture img.src to request the picture again, so is there any other way that this method doesn"t work

Mar.06,2021

  1. if you have already loaded once and the URI is the same when you load again, the browser should load the cache
  2. if the pictures processed in canvas have cross-domain problems, the page rendering is fine, but the output may be limited (Canvas cross-domain contamination)

img.onload=function () {canvas drawing to base64}
img.src='xxxx'


Thank you for following the situation. Some special needs can not be written js implementation has been solved through screenshot

Menu