html2canvas: Problems with background images
Hi, guys!
Thanks for your work, h2c is an awesome tool! I have one small issue on page: http://king.fi/site/ - background image from body { … background: #070707 url(…/img/bg.jpg) no-repeat 50% 0; doesn’t render. With simple calling of h2c:
html2canvas($('body'), {
allowTaint: false,
logging:true,
onrendered: function (canvas) {
document.body.appendChild(canvas);
}
});
and with your test console http://html2canvas.hertzen.com/screenshots.html I have the same results:
Original:

Rendered:

html2canvas: 0.4.0 MacOs 10.6 Chrome 29.0.1547.62
Thanks!
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 56 (21 by maintainers)
i could not render background images and it seemed to be cover or contain background size, so i’ve changed line 350 in 0.4.1 version to:
topPos = isNaN(parseInt(bgposition[1], 10)) ? topPos : parseInt(bgposition[1], 10);
and it works!
Hi @gopiss,
Use corse option.
I second that, fperich, you are my favourite person right now!
fperich u rock man !! thanks
I’ve notice that if I remove background-size: cover; from my class=“mc-image” it works.
Thank you fperich 😄 it worked well
@fperich u help me a lot!Thanks a lot!
Thanx fperich it worked for me!!
Temporary fix, use:
background:url(“…base64…”)
and dont use <img src=“base64” and neither urls
Also, dont use “sprites” because html2canvas doesnt seem to understand that.