Currently, I am developing a mobile application using Ionic 3. Within the application, I have integrated the Croppr.js library to enable image cropping before uploading it to the server. However, I am facing an issue where I am unable to retrieve the cropped image after using the library. Here is the code snippet that I have experimented with:
index.html
<link href="assets/css/croppr.min.css" rel="stylesheet" />
<script src="assets/js/croppr.min.js"></script>
profile.component.ts
ionViewDidLoad() {
this._croppr = new Croppr('#croppr', {
maxSize: [512, 512, 'px'],
minSize: [128, 128, 'px'],
onCropStart: this.onCropStart,
onUpdate: this.onCropUpdate,
onCropEnd: this.onCropEnd
})
}
onCropEnd(data): void {
console.log("On Crop End: ", data);
}
onCropUpdate(data) {
console.log("On Crop Update: ", data);
}
onCropStart(data) {
console.log("crop start: ", data)
}
home.component.html
<img src="path/to/image.jpg" id="croppr"/>
The problem lies in the fact that the onCropEnd
method only provides me with the dimensions of the cropped image and not the actual cropped image itself. Does anyone have any insights on how I can extract the cropped image as either a File or a base64 string?