0

I'm trying to transform a canvas on html image.

The canvas is display without any problem, in $('#image1') there are some data, but it's not display ? What i have forget ?

Here is a jsfidle with the code : http://jsfiddle.net/mcbjam/tZGcq/

Here is the call i need to perform.

$('#image1').attr('src', image.src);  
3
  • 1
    You forgot to set up a live demo: jsfiddle.net Commented May 19, 2013 at 22:24
  • @icktoofay I'm assuming that OP wanted to include a live demo, but forgot. (I'm an optimist :-).) Commented May 19, 2013 at 22:27
  • Here is a live demo. Maybe it will work at the end of the question :) Commented May 19, 2013 at 22:32

1 Answer 1

1

You're drawing an image from another domain. When you do this, the canvas becomes tainted, and you can't get at the data any more because that might reveal data from that other domain that you normally wouldn't be able to access.

You can fix this by copying the image file to your own domain and then using a relative URL to access it.


Additionally, you'll probably want to call convertCanvasToImage from inside the img.onload callback, but that's not your primary problem.

Sign up to request clarification or add additional context in comments.

11 Comments

The fix is to have a simple script on your server to act as a proxy. Something as simple as <?php readfile($_GET['filename']); ?> accessed by proxy.php?filename=http://images/aviary.com/imagesv5/feather_default.jpg
@Kolink: I'd hope it wouldn't be that simple: proxy.php?filename=/etc/passwd
Does there any way to do so without having to upload the image on my domain ?
@icktoofay True XD McbJam: You can use my script, but make sure you add some validation in there, such as making sure the file starts with http://
@McbJam: I'm not all that familiar with document.domain but I'm pretty sure that won't work, but by all means go ahead and try.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.