잡히지 않은 보안 예외를 해결하려면 crossorigin을 추가해야 합니다. 속성:
<img id = "myid" crossorigin = "anonymous" src="https://www.tutorialspoint.com/images/seaborn-4.jpg?v=2"> function getBase64() { var myImg = document.getElementById("myid"); var c = document.createElement("canvas"); c.width = myImg.width; c.height = myImg.width; var context = c.getContext("2d"); context.drawImage(img, 0, 0); var dataURL = c.toDataURL("image/png"); alert(dataURL.replace(/^data:image\/(png|jpg);base64,/, "")); } getBase64();