fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

getCroppedCanvas() is return null on firefox. Angular 8 And CropperJS 1.5.6 #1060

Closed luis-28b closed 5 years ago

luis-28b commented 5 years ago

I'm using cropperjs on my Angular 8 Project. My code is running well in Chrome (Ubuntu 18.04, Windows, MacOS and IOS). But, in Firefox there's a problem when I call the function getCroppedCanvas, because is returning null. Here's the relevant code:

import Cropper from 'cropperjs';

export class CropperComponent implements OnInit {
     public cropper: Cropper;
     public options = {
          aspectRatio: this.aspectRatio,
          movable: true,
          scalable: true,
          zoomable: true,
          viewMode: 0,
          checkCrossOrigin: true,
          responsive: true
     }

     // When I crop the image, after I select the file:
    const imageToCropper = this.cropper.getCroppedCanvas({
      fillColor: this.colorSelected,
      imageSmoothingEnabled: true,
      height: 512,
      width: 384
    });
   // imageToCropper is null on Firefox only
}

Thanks!

fengyuanchen commented 5 years ago

Do you call the getCroppedCanvas within a ready event handler?

PS: Please open an issue on Cropper.js, not here.