Snippets

Convert canvas to an image with JavaScript

Assuming modifications to the image have been made, you can easily convert the canvas data to image data with the following snippet. The code above magically converts the canvas to a PNG data URI!

// Converts canvas to an image
function convertCanvasToImage(canvas) {
	var image = new Image();
	image.src = canvas.toDataURL("image/png");
	return image;
}

Source: http://davidwalsh.name/convert-canvas-image...

Share this snippet

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!