thinksoftware / meteor-image-resize-client

Meteor - Client Side Image Resize
37 stars 9 forks source link

quality of resized image is poor #7

Open achirkof opened 8 years ago

achirkof commented 8 years ago

Hello. Thanks for the great package. It is simle to implement and use. But only one drowback - poor quality after resize. Is it possible to add some parameter to define image quality?

achirkof commented 8 years ago

As I understand it is only need to add some smooth to the resized image. I found example how to make image smoothing here http://stackoverflow.com/a/17862644/1709413. But I can't modify package because I know nothing about canvas . Can you add some anti-aliasing to resized image?

card-b commented 8 years ago

This isn't the best solution, and while it's probably bad practice (it's definitely ugly), you can call the resize method recursively to get the same effect, though it doesn't seem to affect speed that much.

Example:

Resizer.resize(document.getElementById('image-upload').files[0], {width: 800, height: 600, cropSquare: false}, function(error, resultFile1){
    Resizer.resize(resultFile1, {width: 600, height: 450, cropSquare: false}, function(error, resultFile2){
        Resizer.resize(resultFile2, {width: 400, height: 300, cropSquare: false}, function(error, resultFile3){
            uploader.send(resultFile3, function (error, downloadUrl) {
                if (error) {
                // Log service detailed response.
                    console.error('Error uploading', uploader.xhr.response);
                    alert (error);
                }
                else {
                    console.log(downloadUrl);
                }
            });
        });
    }); 
});
achirkof commented 8 years ago

@cheqitout-dev thank you for advice. I take a decision to use meteor-files package to upload images(or any type of files) from client side also + imagemagick to manipulate images.