Skip to content

Strange behavior with lighteweight images #6

Description

@Slava191

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)

            });
            

        })

    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions