cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Not working first time #141

Closed oztek22 closed 7 years ago

oztek22 commented 7 years ago

Every time when I try to upload a new Image in cropper2(Also in example given in runtime.) It isn't showing the 1st time after removing cache and then it works as expected. Can you please look into this matter?

cstefanache commented 7 years ago

Can you please let me know the browser that you are using and describe reproducing steps?

oztek22 commented 7 years ago

I'm using it in ng2-modal. I tried it on both chrome and firefox. and I only changed the cropperSetting which is as below.


 this.cropperSettings.width = 300;
        this.cropperSettings.height = 160;
        this.cropperSettings.keepAspect = true;

        this.cropperSettings.croppedWidth = 750;
        this.cropperSettings.croppedHeight = 400;

        this.cropperSettings.canvasWidth = 451.367;
        this.cropperSettings.canvasHeight = 180;

        this.cropperSettings.minWidth =  300;
        this.cropperSettings.minHeight = 160;

        this.cropperSettings.rounded = false;
        this.cropperSettings.minWithRelativeToResolution = false;

        this.cropperSettings.cropperDrawSettings.strokeColor = 'rgba(255,255,255,1)';
        this.cropperSettings.cropperDrawSettings.strokeWidth = 2;
        this.cropperSettings.noFileInput = true;

        this.data1 = {};

Edit: Also I'm using xampp server not NPM.

oztek22 commented 7 years ago

Now it's working after adding delay in setImage.

let timeoutId = setTimeout(() => {
                          this.cropper2.setImage(image);
                        }, 10);

I think it's getting Image even before it's decoded or something.

TeemoWan commented 7 years ago

+1, on safari

------WebKitFormBoundaryBpQtBavqkrpJdE4n Content-Disposition: form-data; name="photo"; filename="avatar.png" Content-Type: application/octet-stream

------WebKitFormBoundaryBpQtBavqkrpJdE4n--

cstefanache commented 7 years ago

Tried on Chrome, Safari on Mac but unable to reproduce it. Can you please let me know which Env/Browser versions you use?

TeemoWan commented 7 years ago

0.8.3 OK

cstefanache commented 7 years ago

Thanks!