tsayen / dom-to-image

Generates an image from a DOM node using HTML5 canvas
Other
10.21k stars 1.68k forks source link

Gradient color not properly exported #448

Open stevdza-san opened 1 year ago

stevdza-san commented 1 year ago

First I want to say thank you for making this library, it's quite useful. :) I've experience a strange result while trying to export an element colored in gradient(two colors). The image that I've exported is not the same as the one I have on my page. The exported one, looks like a single color, and not two color gradient. I'm using FileSaver lib for image exporting btw.

Element on my website: 11

Exported Image: pretty-ko

wsl0520 commented 1 year ago

@stevdza-san 我按照下面的方式可以正确导出渐变色,你可以试下,希望对你有用

image

渐变色的样式写在内层元素gradientContent身上,即不要直接写在ID元素上

Nderim1 commented 11 months ago

Hi @wsl0520, that did not work for me. Created an inner element with the gradient styles and still the exported image is in a solid color. Do you have any other ideas on how to fix this?