Closed fregante closed 7 years ago
Do you have any ideas on how to do this? 😄
Sure thing, I would accept a pull request for making this Node only. My main decision to use paper.js was the ease of implementation of this colour average detection; basically the guts of the module are these seven lines;
const rect = new paper.Path.Rectangle(
i,
0,
chunk,
height
);
stops.push(colourStop(raster.getAverageColor(rect).toCSS(true), i));
https://github.com/ben-eb/postcss-resemble-image/blob/master/src/resembleImage.js#L54-L60
So with this code I could get the module working quickly. I think this is also possible using jimp if the image was cropped into vertical chunks and then averaged using something like https://github.com/bencevans/pixel-average. I'd like to leave this discovery to someone else if they would like to send a pull request, for me this implementation is fast enough; much better than manually using Photoshop!
Fixed in https://github.com/ben-eb/postcss-resemble-image/commit/f09a97bed79e3d835f6def3445da49f5a2ac81ec. Waiting for the build to pass, then I'll publish a new major version.
This is an excellent way to automate this, but I'm wondering if it could use a node-only solution. Having to install non-npm dependencies complicates setup and lengthens CI builds.