Tag image to color palette javascript