1904labs / dom-to-image-more

Generates an image from a DOM node using HTML5 canvas
Other
454 stars 98 forks source link

[Question] Is that possible to run dom-to-image on NodeJS? #48

Open BrunoQuaresma opened 2 years ago

BrunoQuaresma commented 2 years ago

Hi folks,

Just a quick question. Is that possible to run dom-to-image on NodeJS?

ghost commented 2 years ago

You need window.getComputedStyle, so perhaps a headless browser instance would make it work

BrunoQuaresma commented 2 years ago

Yes, I'm already using a headless browser, but it is pretty slow, so I was trying to find a better alternative. Thank you.

ghost commented 2 years ago

Crazy idea - just use https://github.com/jsdom/jsdom

BrunoQuaresma commented 2 years ago

I tried, but it didn't work. It gets an error related to canvas even after use node-canvas. 😞

ghost commented 2 years ago

zm-cttae commented 1 year ago

There was a perf-hitting extreme CSS optimisation added in #37 for SVGs.

There's plans to bring it back in #92 as a much quicker post-processing op. Choice of browser is also probably important. But I have no data to suggest anything more than "maybe MS Edge".

yelban commented 1 year ago

Curious to know if it works with node + jsdom

anshumanv commented 5 months ago

Revisiting here in 2024...