Vibrant-Colors / node-vibrant

🎨 Extract prominent colors from an image
MIT License
2.02k stars 108 forks source link

Get median of colors from multiple images #74

Closed alirezavalizade closed 2 years ago

alirezavalizade commented 6 years ago

I'm looking to something like this:

Vibrant.from(['path/to/image1', 'path/to/image2']).getPalette((err, palette) => console.log(palette))

maxcr commented 6 years ago

Just loop it. I have one for loop regex all urls to sanitize them and save them to an array. Then I have another loop feed them to the Vibrant promise which writes the colors to my div "cards".

maxcr commented 6 years ago

Oh wait you mean the median of the colors of the two images combined?

alirezavalizade commented 6 years ago

:) Yes exactly @maxcr

1j01 commented 6 years ago

In Node.js you could use https://www.npmjs.com/package/merge-img, altho if the images are not the same size, you'll likely get a background color in the mix, so you might want to do something a little more custom, possibly with the underlying module https://www.npmjs.com/package/jimp

In the browser, or with node-canvas, you could do something like:

function whenAllImagesAreLoaded(){
  var canvas = document.createElement("canvas");
  var ctx = canvas.getContext("2d");
  canvas.width = imgs.length * 200;
  canvas.height = 200;
  imgs.forEach(function(img, index){
    ctx.drawImage(img, index * 200, 0, 200, 200);
  });
}
crutchcorn commented 5 years ago

Good workaround for now @1j01.

I'll mark as feature request for now and edit the title to be clearer

sandstrom commented 3 years ago

Since this can be solved in application code (as explained above), maybe it could be closed? (or moved to discussions, though you'd have to enable that for this repo first).

By closing some old issues we reduce the list of open issues to a more manageable set.

Many open-source projects expand their scope too much, and become difficult to maintain. It's usually better to keep the scope smaller, making it easier to maintain.

crutchcorn commented 2 years ago

I agree that this seems out-of-scope and something we should move to user-space.

Our rewrite to a monorepo should help with this, but it's far from ready