Flickr 支持 CORS 吗? getImageData 出现安全错误
你好亲爱的社区。
我正在尝试从 Flickr 获取的图像中创建提取颜色。当我尝试使用 getImageData() 处理画布中的图像时,这一切都非常有效。
正如通过 WHATWG 所描述的,将图像加载到画布中,设置一个标志,这样您就无法对其进行操作。所以我的问题是 FLICKR 支持 CORS 吗?
<script type="text/javascript">
var img= new Image;
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var src = "fetched-flickr-image-url";
img.crossOrigin = "Anonymous";
img.src = src;
img.onload = function() {
ctx.drawImage( img, 0, 0 );
var image_data = ctx.getImageData(0, 0, 100, 100);//Throw the Security error
}
});
</script>
我还尝试进行图像处理,但这是一个非常繁重的过程(处理 250 张图像大约需要 4 分钟)。
如果您有任何线索,请联系我。
环境:Mac OSX、HTML5、jQuery
Hello dear community.
I'm trying to create extract colors from images fetched from Flickr. That all works really great to the point when I try to process that images in canvas with getImageData().
As described through WHATWG loading an image into canvas set a flag so you cannot maniplate that. So my question is does FLICKR support CORS?
<script type="text/javascript">
var img= new Image;
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var src = "fetched-flickr-image-url";
img.crossOrigin = "Anonymous";
img.src = src;
img.onload = function() {
ctx.drawImage( img, 0, 0 );
var image_data = ctx.getImageData(0, 0, 100, 100);//Throw the Security error
}
});
</script>
I also tried to do the image processing in but thats a really heavy process (took about 4mins to process 250 images).
If you have any clues just ping me.
Enviroment: Mac OSX, HTML5, jQuery
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还没有;请参阅此处进行讨论。
他们现在似乎正在发送图像的 CORS 标头,但带有
Access-Control-Allow-Origin: http://www.flickr.com
,这没有太大帮助,但至少他们正在发送现在的标题。Not yet; see here for discussion.
They now appear to be sending CORS headers for images but with
Access-Control-Allow-Origin: http://www.flickr.com
, which isn't much help but at least they're sending the headers now.