danielepiccone / ditherjs

A javascript library which dithers an <img> using a fixed palette
http://danielepiccone.github.io/ditherjs/
131 stars 22 forks source link

Node examples? #1

Closed bradparks closed 8 years ago

bradparks commented 9 years ago

Hey! I'm playing around with node and dithering and would love to see an example of this running in node. Do you have one somewhere? I'm just not sure where the image data/context would come from?

https://github.com/dpiccone/ditherjs/blob/master/src/ditherjs.js#L359-L362

I just saw a node export at the bottom of the src, and thought it may have been tried?

https://github.com/dpiccone/ditherjs/blob/master/src/ditherjs.js#L414

Thanks!

danielepiccone commented 8 years ago

The whole library is heavily dependent on the canvas element and it's context. You could try coupling it with https://github.com/Automattic/node-canvas

lucawyss commented 8 years ago

I did it a try using metalsmith and jimp: https://github.com/lucawyss/metalsmith-dither it's heavily inspired by DitherJs (kind of fork).

I just change the output of the dithering function to send it to Jimp.write() function.

ps: I really love this plugin btw! thanks @dpiccone