Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageMagickHelp.js improve #105

Closed
hjyssg opened this issue Nov 26, 2020 · 0 comments
Closed

imageMagickHelp.js improve #105

hjyssg opened this issue Nov 26, 2020 · 0 comments

Comments

@hjyssg
Copy link
Owner

hjyssg commented Nov 26, 2020

function isConertable() =>单独做成一个 post
在client先问可不可以转换,然后再转换。两个 请求。

module.exports.minifyOneFile

不在通过 oldAvgImgSize判断

async function convertImage(imgFilePath, outputImgPath, oldAvgImgSize){
    try{
        let opt;

         const stat = await pfs.stat(p);
         const oldImgSize =    stat.size;
        if(oldImgSize > img_reduce_resolution_threshold){

            opt = [imgFilePath, "-strip", "-quality", img_convert_quality, "-resize", `${img_reduce_resolution_dimension}\>`, outputImgPath ];
        }else{
            opt = [imgFilePath, "-strip", "-quality", img_convert_quality, outputImgPath ];
        }

        let {stdout, stderr} = await execa("magick", opt);
        return {stdout, stderr};
    }catch(e){
        logFail("[convertImage]", e);
    }
}
@hjyssg hjyssg closed this as completed Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant