indus / ncc

node-chrome-canvas || a simple to use and performant HTML5 canvas for Node.js
Other
172 stars 6 forks source link

if you find it hard to install node-canvas try ncc #4

Open indus opened 7 years ago

indus commented 7 years ago

a lot of issues in node-canvas deal with installation problems:

https://github.com/Automattic/node-canvas/issues/919 https://github.com/Automattic/node-canvas/issues/913 https://github.com/Automattic/node-canvas/issues/911 https://github.com/Automattic/node-canvas/issues/905 https://github.com/Automattic/node-canvas/issues/901 https://github.com/Automattic/node-canvas/issues/890 https://github.com/Automattic/node-canvas/issues/871 https://github.com/Automattic/node-canvas/issues/854 https://github.com/Automattic/node-canvas/issues/852 https://github.com/Automattic/node-canvas/issues/796 https://github.com/Automattic/node-canvas/issues/788 https://github.com/Automattic/node-canvas/issues/779 https://github.com/Automattic/node-canvas/issues/771 https://github.com/Automattic/node-canvas/issues/768 https://github.com/Automattic/node-canvas/issues/755 https://github.com/Automattic/node-canvas/issues/752 https://github.com/Automattic/node-canvas/issues/751 https://github.com/Automattic/node-canvas/issues/745 https://github.com/Automattic/node-canvas/issues/731

With ncc you just need an installation of chrome(-ium) on your system and everything should be fine.

worc commented 7 years ago

what's ncc?

indus commented 7 years ago

There is a readme: https://github.com/indus/ncc/blob/master/README.md

worc commented 7 years ago

ah, duh. i'm on the ncc repo. i didn't catch that since i was bouncing around the node-canvas issues.

LinusU commented 7 years ago

Cool project! Skimmed the documentation quickly and it seems like the API isn't strictly compatible though? Since you need a few extra call to actually send the stuff back and forth over the websocket; or did I miss anything?

indus commented 7 years ago

@LinusU No it isn't 100% compatible. NCC always gives you funtion back that you have to call to actually do something. But this additional function call sould be the only big difference.

LinusU commented 7 years ago

Have you measured performance compared to node-canvas?

indus commented 7 years ago

No - but basic canvas operations should take the same time as if you run them in your browser. Only "syncing" between node and the browser gives some overhead (especially if you want to get back a giant image: base64-encoding and transfering over websocket takes some time). So it really depends on the situation. If you have frequent tasks with only few comments the overhead will add up alot. For a few big tasks with a lot of comments and only a single sync in the end it will be less noticeable.

indus commented 7 years ago

I think the main benefit is not performance but easy setup on windows and 100% pixel-precise results in comparison to the browser (because a browser is doing the work ;-)

indus commented 7 years ago

If you have a very special case and don´t need a general canvas API you may be better of using https://bestof.js.org/projects/puppeteer and implement it using the ncc comunication as a concept.

setpixel commented 7 years ago

This doesn't work on a headless system which is why anyone wants to run canvas in the first place. I don't see what ncc solves for.

LinusU commented 7 years ago

Also, for anyone having troubles installing node-canvas, I would recommend using the prebuilt binaries which can be fetched by using the package canvas-prebuilt.

npm install --save canvas-prebuilt
const Canvas = require('canvas-prebuilt')
indus commented 7 years ago

@setpixel it works headless.