nolanlawson / blob-util

Cross-browser utils for working with binary Blobs
https://nolanlawson.github.io/blob-util
Apache License 2.0
503 stars 45 forks source link

Tainted Canvas Error blobUtil.imgSrcToBlob #55

Closed ifahadkhan closed 5 years ago

ifahadkhan commented 6 years ago

Hi, I am getting error : DOMException: Failed to execute 'toBlob' on 'HTMLCanvasElement': Tainted canvases may not be exported.

My code is : blobUtil.imgSrcToBlob('http://scentglobal.com/ScentImage/VIALS.jpg','image/jpeg',).then(function (imgblob) {...}

When I try to use Anonymous for Cors I get error:

Access to Image at 'http://scentglobal.com/ScentImage/VIALS.jpg' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.

Any idea what I am doing wrong here.

nolanlawson commented 5 years ago

You have to enable CORS on the server hosting the images, and then use anonymous. See Stack Overflow for details: https://stackoverflow.com/questions/20035101/why-does-my-javascript-get-a-no-access-control-allow-origin-header-is-present