I am sending an image from front end to backend ( using multer ) . At backend , I want to rotate it multiple times. If 1 rotation is done, I am storing that image in backend itself. For next rotation, I am giving path of the previously rotated image ( which I have stored in backend itself ). Once this process is done, I am sending that image to front end.
At backend I am using Node.js and Sharp library.
But what is happening, that 1st time image is rotating properly. Getting stored at backend but 2nd time gets error that “Image is not there or it is inaccessible”
I checked that there is an image present in respective folder at backend. And I am sending it’s correct path also. ( I tried both relative and absolute path of the image for this process )
Here is the rotation implementation using sharp library.
sharp(resolvedImagePath)
.rotate(rotate)
.toFile(fullQualityOutputPath, (err, info) => {
if (err) {
fullQualityResult = {
success: false,
message: "Error processing full-quality image",
};
} else {
fullQualityResult = {
success: true,
message: "Full-quality image processed",
image_url: fullQualityOutputPath, // Path to the full-quality image
};
}
});
Where am I wrong ? Why "Image inaccessible" type error I am getting ?