npm install gradient-from-image
note: currently only works with promises
var grad = require("gradient-from-image")
const imgUrl = "https://picsum.photos/200/300?image=82";
grad.gr(imgUrl).then(gradient =>{
// this will gives you array of gradients
//change this is to element css el.background="` linear-gradient(${gradient})`"
console.log(gradient);
});