It has been programmed actually for Magento 1.9.x Ultimo Theme Product Page but it can be used for anything else
It creates a colorbox with color of image by analyzing it.
Usage:
//create an Instance of it
var cB = new colorBar({
color: color, // string color name
colorArray: Colors, // js File contains json object with colors and color codes
icon: '', // Fontawesome Icon to show
img: document.querySelector('.gallery-image'),
});