我正在使用 jimp 库来调整图像的对比度并调整其大小。对于某些 jpeg 文件,原始文件无意更改为横向。为什么会这样做?如何防止这种不需要的文件轮换?
async function contrast(file_path, job) {
const destination = `${received_folder}\\${images}\\${job.regNum}\\${job.recievedName}${job.recievedExtension}`;
console.log("file path", file_path);
try {
const file = await Jimp.read(file_path);
file.contrast(0.25).resize(Jimp.AUTO, 2000).quality(100).write(destination);
return true;
} catch (err) {
logger.log("error", `optimization failed ${job.regNum} job id ${job.id}. error: ${err.message}`);
await job.log("error", `the file is damaged. error: ${err.message}`);
return false;
}
}
不要介意文件名,它已重命名。