-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to export the cropped image #3
Comments
Hi there, thank you for posting your question. You need to follow the readme.md, there is a part showing how to use cropperjs methods: Using CropperJS methods: Use @ViewChild in your component to get the element: In your app.component.html <angular-cropper #angularCropper ..> And in your app.component.ts //
// Import AngularCropperjsComponent
import { AngularCropperjsComponent } from 'angular-cropperjs';
//
// Get with @ViewChild
@ViewChild('angularCropper') public angularCropper: AngularCropperjsComponent; Then just call the CropperJS method you want: anywhere in your app.component.ts //
// Get base64
this.angularCropper.cropper.getCroppedCanvas().toBlob((blob) =>{
// blob is your base64..
}); |
Are you using checkCrossOrigin? you need to use it otherwise toBlob won't work. |
see this: fengyuanchen/cropper#119 |
this is what i used for cropperOptions |
Remove checkCrossOrigin(it default to true), leave the config empty {} for now and it will work |
But problem is my image is coming from a separate domain that. So i needed to set checkCrossOrigin to false; |
I solved the problem by allowing cors from server end. Thanks |
Good to hear, unfortunately that is a security limilation of the browser, not the plugin. |
node_modules/angular-cropperjs/angular-cropperjs"' has no exported member 'AngularCropperjsComponent'. why this error is coming |
@Coolhat1177, please open a new issue with this bug |
I can see an export eventEmitter for the cropper. But not sure how to use it. Can you post an example about how to export the cropped image as blob & base64 data?
The text was updated successfully, but these errors were encountered: