Open indus opened 7 years ago
what's ncc?
There is a readme: https://github.com/indus/ncc/blob/master/README.md
ah, duh. i'm on the ncc repo. i didn't catch that since i was bouncing around the node-canvas issues.
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?
@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.
Have you measured performance compared to node-canvas?
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.
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 ;-)
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.
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.
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')
@setpixel it works headless.
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.