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

Work as a util server side. #2

Open
tryggvigy opened this issue Aug 22, 2016 · 4 comments
Open

Work as a util server side. #2

tryggvigy opened this issue Aug 22, 2016 · 4 comments

Comments

@tryggvigy
Copy link

Awesome tool!
It would be very useful if Grade could work with node as well.

Example usecase:

  • Process user profile photos in a background job and extract gradients
  • Save the gradients to a database
  • Serve gradients as placeholders until actual profile pic loads.

For some applications it could be too expensive to calculate the gradients on the client.

@nijikokun
Copy link

nijikokun commented Aug 22, 2016

You could use node-colour-extractor for this, get the top two colours that are used and store those for values for a gradient.

@feross
Copy link

feross commented Aug 23, 2016

@nijikokun Thanks for the link to node-colour-extractor. One advantage this library has over that other one is no native dependency. That means no compilation step on install.

@benhowdle89
Copy link
Owner

I'm totally on board with this, just trying to think how I could adapt Grade to work on the server, without adding too much bloat to the client-side library....

Maybe a sub-project? Happy to hear suggestions...

@feross
Copy link

feross commented Sep 12, 2016

I actually want to use this in an Electron app, so I don't need node support since the DOM is available.

But I want to interact with this as a pure function rather than via the DOM. I want to pass in an image as a Buffer (i.e. Uint8Array) and get back the colors. Then I can set them in the DOM however I like.

That might be a good start. Once this new API exists, then you can just support a canvas option that allows the user to optionally pass in their own canvas implementation, like https://www.npmjs.com/package/canvas. If this parameter isn't specified, then you can just use window.canvas like you currently do.

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