<img>感谢CSS类,我必须应用一些样式.
是否有可能得到dataURL的<img>与CSS样式?
$(function() {
// Original
const imgOriginal = document.getElementById('original');
const c1 = document.getElementById('c1');
let ctx = c1.getContext('2d');
ctx.drawImage(imgOriginal, 100, 100);
// Filtered
const imgFiltered = document.getElementById('filtered');
const c2 = document.getElementById('c2');
ctx = c2.getContext('2d');
ctx.drawImage(imgFiltered, 100, 100);
// Same dataURL :(
console.log(c1.toDataURL(), c2.toDataURL());
console.log(c1.toDataURL() === c2.toDataURL());
})Run Code Online (Sandbox Code Playgroud)
.filter::before {
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: 1;
border: 1px solid red;
}
.filter {
position: relative;
-webkit-filter: sepia(.5) hue-rotate(-30deg) …Run Code Online (Sandbox Code Playgroud)