get average color by image demo npm package install yarn add color-picture // or npm i --save color-picture use import { getAverageRGBA } from "color-picture"; const img = document.querySelector('img'); const backgr = getAverageRGBA(img); document.body.style.backgroundColor = backgr; demo source demo