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

CORS 'Anonymous' not working #31

Closed FKasa closed 7 years ago

FKasa commented 7 years ago

How to replicate:

Go to http://nolanlawson.github.io/blob-util/ Change Kirby src (test/kirby.gif) to external image with CORS Example: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png Paste this in your console:

var img = document.getElementById('kirby');
blobUtil.imgSrcToBlob(img.src,'image/png','Anonymous').then(function (blob) {
  var blobURL = blobUtil.createObjectURL(blob);

  var newImg = document.createElement('img');
  newImg.src = blobURL;

  img.parentNode.appendChild(newImg);
});

Notice CORS error in console.

nolanlawson commented 7 years ago

That image does not appear to have CORS enabled. If I use this CORs-enabled image from Wikipedia, then your example works: https://upload.wikimedia.org/wikipedia/en/thumb/0/06/Wiktionary-logo-v2.svg/35px-Wiktionary-logo-v2.svg.png