How to get image data url in JavaScript?

Posted by Pinki | Updated on

How to get image data url in JavaScript: It is very simple with HTML5 Canvas API, it provides toDataURL() method. The toDataURL() method of the canvas object converts the canvas drawing into a 64 bit encoded PNG URL.

How to get image data url in JavaScript?

We have pass “image/jpeg” as argument to toDataURL() method, to get image data URL in the jpeg format.

Output


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers