将具有外部图像的画布保存到本地文件 [英] Save canvas with external images to local file

查看:191
本文介绍了将具有外部图像的画布保存到本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法保存到本地文件系统一个帆布与加载的图像从外部网站到它?

Is there a way to save to the local filesystem a canvas with loaded images from external websites into it?

如果我尝试用toDataUrl(),它只是trhows a安全错误。在Firefox中,我可以使用鼠标右键单击保存到画布上,但这在Chrome中是不可能的。

If I try with toDataUrl(), it just trhows a Security error. In Firefox I can just save to a file the canvas with the right click, but this is not possible in Chrome.

推荐答案

否,出于安全原因,你不能使用 toDataUrl()

No, for security reasons you can't use toDataUrl().

转换为 cors

< a href =http://simonsarris.com/blog/480-understanding-the-html5-canvas-image-security-rules =nofollow>这里有一点是为什么应该这样 。

这是Firefox中的一个功能,您可以右键单击save-as,因为它的所有本地。如果它是 toDataUrl(),那么网页也可以尝试发送画布数据到服务器,我们不想这样。

It's a feature in Firefox that you can right-click save-as because its all local. If it were with toDataUrl() then the webpage could also attempt to send the canvas data to the server and we don't want that.

右键单击save-as是Opera中的一个请求的功能,并且有一天可能会来到其他浏览器,但我不会在很短的时间内存储功能。

The right-click save-as is a requested feature in Opera and may come to other browsers someday but I wouldn't bank on the functionality existing any time soon.

这篇关于将具有外部图像的画布保存到本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆