Skip to content

Instantly share code, notes, and snippets.

@kypflug
Created June 11, 2015 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kypflug/fdcccc85d859b0e60337 to your computer and use it in GitHub Desktop.
Save kypflug/fdcccc85d859b0e60337 to your computer and use it in GitHub Desktop.
function capturePhoto()
{
var video = document.getElementById('videoTag');
var canvas = document.getElementById('canvasTag');
var videoWidth = video.videoWidth;
var videoHeight = video.videoHeight;
if (canvas.width !== videoWidth || canvas.height !== videoHeight)
{
canvas.width = videoWidth;
canvas.height = videoHeight;
}
var ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment