image-clipper
image-clipper copied to clipboard
Strange behavior with lighteweight images
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)
});
})
}