I am using a jimp library to adjust contrast to image and to resize it. for some jpeg files, the original file changed to landscape without any intention. why does it do it and how can I prevent this unwanted file rotation?
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;
}
}
this is how it looks in folder
before:
don't mind the file name, it was renamed.