根据图像主色更改背景颜色?

时间:2022-04-05 20:20:15

I don't know if this is actually possible but it would be nice if it is! Taaking inspiration from the new iTunes where the background color seems to be set via the (major) color of the artwork image. I'm looking to do something similar with javascript/cs maybe using jQuery, essentially changing the background-color of a div based on an image inside it.

我不知道这是否真的有可能,但如果是的话会很好!从新的iTunes中汲取灵感,其中背景颜色似乎是通过艺术品图像的(主要)颜色设置的。我希望用javascript / cs做类似的事情,也许使用jQuery,基本上根据里面的图像改变div的背景颜色。

1 个解决方案

#1


8  

Here's what you could try out:

这是你可以尝试的:

https://github.com/lokesh/color-thief

This library has a pretty cool demo: http://lokeshdhakar.com/projects/color-thief/

这个库有一个非常酷的演示:http://lokeshdhakar.com/projects/color-thief/

Found here: Get average color of image via Javascript

在此处找到:通过Javascript获取图像的平均颜色

#1


8  

Here's what you could try out:

这是你可以尝试的:

https://github.com/lokesh/color-thief

This library has a pretty cool demo: http://lokeshdhakar.com/projects/color-thief/

这个库有一个非常酷的演示:http://lokeshdhakar.com/projects/color-thief/

Found here: Get average color of image via Javascript

在此处找到:通过Javascript获取图像的平均颜色