How to get the average or main color from an image with javascript?

后端 未结 5 1471
失恋的感觉
失恋的感觉 2020-12-30 12:41

what i want is to the the HEX or the RGB average value from an image to the another div background this color.

So if i upload an image with a ot of red i get somethi

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 13:47

    For finding that average color:

    1. Put Image on Canvas
    2. Resize image to 1px by 1px
    3. Get the color of the resulting pixel(This pixel will be the calculated average)

提交回复
热议问题