需要帮助,当我通过css将边界半径应用于imgae时,它无法正确渲染,渲染图像应该是相同的预览图像。我使用html2canvas将div转换为图像。
附图供参考,第一个是带有border-radius的正常预览,第二个是没有border-radius的正常预览。
text!
Generated image
Image:
CSS
#mydiv {
width: 300px;
height: 200px;
background:#000;
}
#mydiv img {
width: 200px;
height: 200px;
border-radius:100%;
}
JS
html2canvas([document.getElementById('mydiv')], {
onrendered: function (canvas) {
//document.getElementById('canvas').appendChild(canvas);
var data = canvas.toDataURL('image/png');
// AJAX call to send `data` to a PHP file that creates an image from the dataURI string and saves it to a directory on the server
var image = new Image();
image.src = data;
document.getElementById('image').appendChild(image);
}
});