Embed external images for use in HTML canvas?

Posted by Philipp Lenssen on Stack Overflow See other posts from Stack Overflow or by Philipp Lenssen
Published on 2010-04-14T09:09:59Z Indexed on 2010/04/14 9:13 UTC
Read the original article Hit count: 268

Filed under:
|
|
|

I'm using JavaScript to load an image into my Canvas element in Firefox. This works fine for local images, but throws a security exception for external images. Is there any way to avoid this security exception, one that does not involve my server having to act as proxy to load the image locally (because that would stress my server)?

PS: The current code is similar to this:

var img = new Image();
var contextSource = canvasSource.getContext('2d');
contextSource.drawImage(img, 0, 0);
// get image data to do stuff with pixels
var imageDataSource = contextSource.getImageData(0, 0, width - 1, height - 1);

© Stack Overflow or respective owner

Related posts about canvas

Related posts about JavaScript