fengyuanchen / cropper

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

Since version 3.1 getCroppedCanvas doesn't resize the image #970

Closed samuel-clara closed 6 years ago

samuel-clara commented 6 years ago

I noticed now that since version 3.1 the cropper doesn't resize the image to the desired width. This is my code that worked perfectly with previous versions.

uploadSubmit.click(function() {

            croppedImg.cropper('getCroppedCanvas',{
                width: 600,
                fillColor: '#fff'
            }).toBlob(function (blob) {
                var formData = new FormData();

                formData.append('croppedImage', blob);
                formData.append('type', uploadPhpType);

                $.ajax('media-upload.php', {
                    method: "POST",
                    data: formData,
                    processData: false,
                    contentType: false,
                    dataType: "json", //the return type data is jsonn
                    success: function ( data ) {
                        [....]
                    },
                    error: function () {                     
                            [....]
                    }
                });
            }, 'image/jpeg', 0.80);
        });
fengyuanchen commented 6 years ago

Any demo or screenshots?

samuel-clara commented 6 years ago

It's for me difficult to provide you a demo because I integrated it in a CMS in italian language. There are no errors in the console and the uploaded image is correctly cropped but the size remains the same as the selected image.

Would be a pleasure to provide you additional info if you need.

samuel-clara commented 6 years ago

Pehaps I have understood: using getCroppedCanvas you have to specify width and hight values. With older versions width value was sufficient. So returning to my code, this works:

croppedImg.cropper('getCroppedCanvas',{
                width: 600,
                height: 600 / 1.6,
                fillColor: '#fff'
            }).toBlob {[...]}, 
'image/jpeg', 0.80);
        });
fengyuanchen commented 6 years ago

Cannot reproduce. Please try on the latest version again.

samuel-clara commented 6 years ago

Problem still remains, previously it was possible to use getCroppedCanvas without specifing the image height (just width) and now without the height property the file remains with the original resolution.

In addition by doing so the image seems to lose more quality.

samuel-clara commented 6 years ago

Original image linas-bam-518045-unsplash

Uploaded image (imageSmoothingQuality=low) offerta-1 1

Uploaded image (imageSmoothingQuality=medium) offerta-2

fengyuanchen commented 6 years ago

If you cannot provide a minimal example for reproduce, I will close this issue soon.