Last active
June 2, 2017 09:50
-
-
Save Deliaz/716f686153b0d97bd0fda9ec1d54e6b8 to your computer and use it in GitHub Desktop.
Revisions
-
Deliaz revised this gist
Jun 2, 2017 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,18 @@ /** * Takes a screenshot from video. * @param videoEl {Element} Video element * @param scale {Number} Screenshot scale (default = 1) * @returns {Element} Screenshot image element */ function getScreenshot(videoEl, scale) { scale = scale || 1; const canvas = document.createElement("canvas"); canvas.width = videoEl.clientWidth * scale; canvas.height = videoEl.clientHeight * scale; canvas.getContext('2d').drawImage(videoEl, 0, 0, canvas.width, canvas.height); const image = new Image() image.src = canvas.toDataURL(); return image; } -
Deliaz created this gist
Jun 2, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ var getImage = function (videoEl, scale = 1) { const canvas = document.createElement("canvas"); canvas.width = videoEl.clientWidth * scale; canvas.height = videoEl.clientHeight * scale; canvas.getContext('2d').drawImage(videoEl, 0, 0, canvas.width, canvas.height); const image = new Image() image.src = canvas.toDataURL(); return image; };