如何防止不需要的文件轮换?

问题描述

我正在使用 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;
  }

}

这是它在文件夹中的样子 前:

before

之后:

enter image description here

不要介意文件名,它被重命名了。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)