I want to create image from my canvas, I'm using kineticjs, but I get error: "Kinetic warning: Unable to get data URL. Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported." I suppose, that it's caused by cross-origin error. In canvas I use localy saved images and address path starts with "file://..". Is there any solution how to create image without apache installing? Thanks.

有帮助吗?

解决方案

Your local hard drive is deemed to be "other domain" by browsers and will taint Canvas.

That's a good thing! You don't want malicious code to get at stuff on your personal drive.

Some workarounds:

  • Install a web server on your computer.

  • Put your image(s) and all files associated with your web app on the desktop (this may/may not help depending on where you got the images to begin with).

  • Temporarily host your images on a site that allows anonymous cross-origin access to your images.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top