Open AmirGilboa opened 6 years ago
You can take the cropped image from this.data.image. This will give you the base 64, then you can convert it to blob and then to a file.
I used this code from SO to convert
private convertImageUriToFile(uri: string) {
const arr = uri.split(',');
const mime = arr[0].match(/:(.*?);/)[1];
const bstr = atob(arr[1]);
let n = bstr.length;
const u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], this.fileName, { type: mime });
}
Which I call with .image property
this.convertImageUriToFile(this.imageData.image
in order to use ng2-file-upload to upload the cropped image to server, i need to get hold of the cropped image, and convert it to javascript File object. Any tip on how to do that?