Guest User

Untitled

a guest
Jul 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. var imagem = $scope.authentication.user.imagem.toString();
  2.  
  3. getDataUri(imagem, function (dataUri) {
  4. logo = dataUri;
  5. console.log("logo=" + logo);
  6. });
  7.  
  8. function getDataUri(url, cb)
  9. {
  10. var image = new Image();
  11. image.setAttribute('crossOrigin', 'anonymous');
  12.  
  13. image.onload = function () {
  14. var canvas = document.createElement('canvas');
  15. canvas.width = this.naturalWidth;
  16. canvas.height = this.naturalHeight;
  17.  
  18. var ctx = canvas.getContext('2d');
  19. ctx.fillStyle = '#fff';
  20. ctx.fillRect(0, 0, canvas.width, canvas.height);
  21.  
  22. canvas.getContext('2d').drawImage(this, 0, 0);
  23.  
  24. cb(canvas.toDataURL('image/jpeg'));
  25. };
  26.  
  27. image.src = url;
  28. }
  29.  
  30. Access to Image at 'https://URL-DA-VARIAVEL/7367506d-9615-4131-8e13-9c13e549e48d.jpeg' from origin 'http://localhost:15495' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:15495' is therefore not allowed access.
Add Comment
Please, Sign In to add comment