In my angular application i have made image upload and preview using,
Html:
<input type='file' (change)="readUrl($event)">
<img [src]="url">
Ts:
readUrl(event:any) {
if (event.target.files && event.target.files[0]) {
var reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
reader.onload = (event: ProgressEvent) => {
this.url = (<FileReader>event.target).result;
}
}
}
As of now everything works fine..
But here the uploaded image is very bigger in size and hence i am in the need to implement auto crop and auto resize of the uploaded image that comes in preview, So that user can see the image in clear way..
Kindly help me to achieve the result of auto crop and resize without using jquery or any other libraries..
Stackblitz: https://stackblitz.com/edit/angular-a7ytbh
Edit:
Tried with javascript way https://jsfiddle.net/t3cgw65L/1/ but here only auto crop functionality is needed.. If we upload an image then only certain part is showing.. It needs to display the face if we upload our picture.. I am in need of uploading profile picture with auto crop and resize as like skype profile picture upload..