I am using this node package:
https://www.npmjs.com/package/sharp
I use it to resize an image and then upload it to amazon S3.
Most images are find but some of them (I assume based on aspect ratio) get rotated.
Is there a way to prevent this or a reason for it?
Here is a copy of the code I am using. imageData is either data taken from an s3 bucket file of from file upload. As you can see I am not calling the rotate function. Is there anyway to 'lock' rotation?
module.exports.resize = function(imageData, width, fileName){
sharp(imageData).resize(parseInt(width), null).toBuffer(function (err, data) {
if (err) throw err;
s3.putObject({
Bucket: aws.bucket,
Key: 'images/' + width + '/' + fileName,
Body: data
}, function (err, data) {
if (err) {
console.log('Failed to resize image due to an error: ' + err);
return {
message: 'Failed to resize image due to an error: ' + err
};
} else {
console.log('s3 image uploaded to ' + 'images/' + width + '/' + fileName);
return {
message: 's3 image uploaded to ' + 'images/' + width + '/' + fileName
};
}
});
});
});