image-clipper icon indicating copy to clipboard operation
image-clipper copied to clipboard

Strange behavior with lighteweight images

Open Slava191 opened this issue 4 years ago • 0 comments

It's not working when i am trying to interract with lightweight images (example: 2.68 kilobyte, 5.36 kilobyte). Promise in my code can't be resolved in lightweight images case. But everything is ok, when aplly it with normal weight images (example: 1 Mb)

    clipperPromise(fileNameWithPath, resizeWidth = 1000){

        return new Promise(function(resolve, reject){

            Clipper(fileNameWithPath, function() {

             if(resizeWidth!== null && this.canvas.width > resizeWidth) this.resize(resizeWidth)

            this.toFile(fileNameWithPath, () => {
                   resolve(fileNameWithPath)
            });

         });

 });

}

Switched to Jimp, and it's work good now in all cases. But in your library speed of resize operation is better! I hope you will fix this issue.

    jimpPromise(fileNameWithPath, resizeWidth = 1000){

        return new Promise(function(resolve, reject){

            Jimp.read(fileNameWithPath, (err, file) => {
                if (err) throw err;

                file
                    .resize(1000, Jimp.AUTO, Jimp.RESIZE_BEZIER)
                    .write(fileNameWithPath); // save

                resolve(fileNameWithPath)

            });
            

        })

    }

Slava191 avatar May 07 '21 19:05 Slava191