Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var imagem = $scope.authentication.user.imagem.toString();
- getDataUri(imagem, function (dataUri) {
- logo = dataUri;
- console.log("logo=" + logo);
- });
- function getDataUri(url, cb)
- {
- var image = new Image();
- image.setAttribute('crossOrigin', 'anonymous');
- image.onload = function () {
- var canvas = document.createElement('canvas');
- canvas.width = this.naturalWidth;
- canvas.height = this.naturalHeight;
- var ctx = canvas.getContext('2d');
- ctx.fillStyle = '#fff';
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- canvas.getContext('2d').drawImage(this, 0, 0);
- cb(canvas.toDataURL('image/jpeg'));
- };
- image.src = url;
- }
- 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