Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use on server-side? #19

Open
ChrisRobston opened this issue Jul 2, 2018 · 4 comments
Open

How to use on server-side? #19

ChrisRobston opened this issue Jul 2, 2018 · 4 comments

Comments

@ChrisRobston
Copy link

Hello. Is there an option to use this package on Node backend?
It is not available on npm, right? If so, why?

@ondras
Copy link
Owner

ondras commented Jul 2, 2018

This project relies on the 2D Canvas API that is primarily found in browsers. There might be some nodejs module that implements Canvas, but I have never tried that. If you find a compatible server-side Canvas implementation, you might be able to run this code server-side. I would package it for NPM then.

@ChrisRobston
Copy link
Author

ChrisRobston commented Jul 2, 2018

Thanks for response @ondras
I will search this topic next few days. Really hope there's the chance to use this beauty to generate previews of images on server-side. It's incredible.

For now Google show me this https://github.com/Automattic/node-canvas
Seems legit.

@Ataraxy
Copy link

Ataraxy commented Jul 7, 2018

It's possible and I've done this before using node-canvas and jsdom. Essentially I created a small piece of html to mimic the html page the library uses, loaded that with jsdom, then used node-canvas in place of the browsers Canvas. I was even able to stream the results from a AWS Lambda to a browser via websockets which was kind of neat since multiple people could 'watch' the generation occur in real time.

Though I don't have any code to demonstrate this with unfortunately as I did it quite a while ago.

@LoggeL
Copy link

LoggeL commented Aug 12, 2019

https://gist.github.com/LoggeL/ffe3204649be0aefa178dab79b5a1a1f

I've automated it with Puppeteer. Might be overkill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants