javascript - Save canvas as jpg to desktop -
this question has answer here:
- html5 canvas png file 4 answers
i trying save image (jpeg) desktop html5canvas. can open in new window window.open(canvas.todataurl('png'), "");
, how can save desktop? thanks.
download attribute
there new download attribute in html5 allow specify file-name links.
i made saving canvas. has link ("download image") -
<a id="downloadlnk" download="yourfilename.jpg">download image</a>
and function:
function download() { var dt = canvas.todataurl('image/jpeg'); this.href = dt; }; downloadlnk.addeventlistener('click', download, false);
you can change file-name dynamically setting attribute downloadlnk.download = 'myfilename.jpg'
.
demo archives.
Comments
Post a Comment