There are a couple ways to get around this, but all of them will require at least temporarily hosting the image on your server.(有几种解决方法,但是所有这些方法都至少需要在服务器上临时托管映像。)
The simplest option would be to write a simple cgi script that takes an url as a parameter, fetches the image at that url, and sends it on to the browser as though it was on your server.(最简单的选择是编写一个简单的cgi脚本,该脚本将url作为参数,获取该url处的图像,然后将其发送到浏览器,就像它在服务器上一样。) You could also use a file upload form if you want the user to be able to select a local image.(如果希望用户能够选择本地图像,也可以使用文件上传表单。)
Note that if you do this, you would want to be aware of the security implications of grabbing user-selected files and serving them as if they were on your own server.(请注意,如果执行此操作,则需要了解捕获用户选择的文件并将其提供给用户的文件就像在您自己的服务器上一样对安全性的影响。) You would, at a minimum, want to make sure the files were valid images, and not, say, javascript files (which might lead to code injection attacks).(您至少要确保文件是有效图像,而不是javascript文件(这可能导致代码注入攻击)。)
The reason exporting of tainted canvas data is disallowed is that it's a user security issue.(禁止导出受污染的画布数据的原因是这是用户安全问题。) Remote sites can send different images to different users, and if your site can gain access to that just by drawing it on a canvas, that method could be used to steal a user's private data.(远程站点可以将不同的图像发送给不同的用户,如果您的站点仅通过在画布上绘制就可以访问该图像,则可以使用该方法来窃取用户的私人数据。) For example, Amazon used to let website owners embed an image in their site that would end up being a customized ad including a greeting and the end-user's name.(例如,亚马逊过去曾让网站所有者在他们的网站中嵌入图片,而该图片最终将成为包含问候语和最终用户名称的定制广告。) If you could paint that on a canvas and export the data, you could send that data back to your webserver and OCR it to learn the name of the end-user.(如果可以将其绘制在画布上并导出数据,则可以将该数据发送回Web服务器并对其进行OCR,以了解最终用户的名称。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…