DEV Community

artydev
artydev

Posted on • Updated on

Display base64 images

Here is a nice tips from Kevin

You can test it here : img64

function imgDisplay (img) {
  let buffer = Uint8Array.from(atob(img), c => c.charCodeAt(0));
  let blob = new Blob([buffer]);
  let url = URL.createObjectURL(blob);
  let imag = document.createElement("img");
  imag.src = url;
  document.body.appendChild(imag)
}

imgDisplay(img64)
Enter fullscreen mode Exit fullscreen mode

Latest comments (0)