我正在尝试从YouTube缩略图中获取配色方案,以更好地将YouTube视频与整个网站设计融合在一起,我想知道是否有任何方法可以做到这一点?
我已经尝试使用color-thief (https://github.com/lokesh/color-thief) 和以下代码(但没有成功):
有没有绕过这个问题的方法,或者在不下载YouTube上的缩略图并将其保存在我的服务器上的情况下获取调色板的方法?
我已经尝试使用color-thief (https://github.com/lokesh/color-thief) 和以下代码(但没有成功):
var img = new Image();
img.onload = function () {
var colorThief = new ColorThief();
colorThief.getColor(img);
};
img.crossOrigin = 'Anonymous';
img.src = 'http://img.youtube.com/vi/NuEfvIca0XU/mqdefault.jpg
从这里我只是得到了这个错误:
Image from origin 'http://img.youtube.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access
有没有绕过这个问题的方法,或者在不下载YouTube上的缩略图并将其保存在我的服务器上的情况下获取调色板的方法?
nodejs
专家,但我更喜欢这种方式:1. 从 YouTube 下载图像。2. 定义颜色调色板。3. 将其存储到数据库中。4. 删除图像。 - Alex Antonov