I have the problem with saving photo with CanvasRenderingContext2D.filter. When I connect to video and try to take a shot without any filters, it saves normally. However, after adding some filters to canvas, it is saving as HTM file or return previous photo without filters if it was made. The weird is, that while downloading that screenshot manually by clicking on it, it does have own toDataUrl, downloads normally and contains filter but while saving it using toDataUrl, it still doesn't see that picture. What should I do to save photos with these filters?
Here is the piece of my code:
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var video = document.getElementById("video");
document.getElementById("snapshot").addEventListener("click", function() {
if ($('video').hasClass('blur')) {
context.filter ="blur(2px)";
}
else {
context.filter= "";
}
context.drawImage(video, 0, 0);
});
document.getElementById("download").addEventListener("click", function() {
download.href = canvas.toDataURL("image/jpeg");
};
.blur {
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-ms-filter: blur(3px);
-o-filter: blur(3px);
filter: blur(3px);
}
<video id="video" autoplay></video>
<canvas id="canvas"></canvas>
<button id="download" download="picture" href=""></button>