Skip to content
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

Maximum Call Stack exceed on cropping image #124

Open
muhammadnabeelmehmood opened this issue Oct 25, 2022 · 2 comments
Open

Maximum Call Stack exceed on cropping image #124

muhammadnabeelmehmood opened this issue Oct 25, 2022 · 2 comments

Comments

@muhammadnabeelmehmood
Copy link

When a user uploads an image, I convert it to base64 and then crop it.

Upload Image Code

const reader = new FileReader();
reader.onload = (event) => {
 this.uploadImage = event.target.result;
};
reader.readAsDataURL(e.target.files[0]);

Vue Cropper Component

<vue-cropper
                      ref="cropper"
                      :auto-crop="true"
                      :data="data"
                      :min-crop-box-height="150"
                      :min-crop-box-width="150"
                      :src="uploadImage"
                      :view-mode="3"
                      :zoom-on-wheel="false"
                      @crop="fixDimensionCrop"
                    />

On this function I'm getting an error maximum call stack exceed.

fixDimensionCrop(event) {
          
            let width = event.detail.width;
            let height = event.detail.height;

            if (
                width < this.minCroppedWidth
          || height < this.minCroppedHeight
          || width > this.maxCroppedWidth
          || height > this.maxCroppedHeight
            ) {
                this.$refs.cropper.setData({
                    width: Math.max(this.minCroppedWidth, Math.min(this.maxCroppedWidth, width)),
                    height: Math.max(this.minCroppedHeight, Math.min(this.maxCroppedHeight, height)),
                });
               
            }
        },

fixDimensionCrop function is being called when user resize crop canvas.

@Agontuk Kindly have a look at it.

@muhammadnabeelmehmood
Copy link
Author

I get this error while using base64, but everything is good when I use the local directory image path.

@AndrewSithole
Copy link

Also getting this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants