Closed alirezavalizade closed 2 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"
.
Oh wait you mean the median of the colors of the two images combined?
:) Yes exactly @maxcr
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);
});
}
Good workaround for now @1j01.
I'll mark as feature request for now and edit the title to be clearer
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.
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
I'm looking to something like this:
Vibrant.from(['path/to/image1', 'path/to/image2']).getPalette((err, palette) => console.log(palette))