0 votes
1 view
in Web Technology by (6.8k points)

I have written some code for image capturing using JavaScript/jQuery. Below is the code:

function capture_image(){ 


    var p = webcam.capture();


    alert("capture complete "+p); //getting true here

     var img = canvas.toDataURL("image");

    var item_image = img.replace(/^data:image\/(png|jpg);base64,/, "") ; 



The item_image prints the base64 format, How to convert that base64 to image and how to use that path in javascript clientside.

1 Answer

0 votes
by (6.8k points)

You can just create an Image object and put the base64 as its src, including the data:image part like this:

var image = new Image();

image.src = 'data:image/png;base64,iVBORw0K...';


Want to be a Full Stack Developer? Check out the Full Stack developer course from Intellipaat.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !