I have the following code used to resize a base64Image. When I do the resize, it is a smaller file, but when I try display the image, it is just pitch black.
Any ideas what i am doing incorrectly? Thanks
resize(base64Img, width, height) { var img = new Image(); img.src = 'data:image/jpeg;base64,'+base64Img; var canvas = document.createElement('canvas'),ctx = canvas.getContext('2d'); canvas.width = width; canvas.height = height; ctx.drawImage(img, 0, 0, width, height); return canvas.toDataURL("image/jpeg"); }
and
this.base64Image = this.resize(this.base64Image, 100, 100);
html
<img src="{{ base64Image }}" />