When uploading images from a mobile device such as an iPhone, images often appear sideways, unless accessing the image directly in Chrome.
From what I've read on here, this has to do with an image exif orientation data that a browser like Chrome would ignore.
What are the solutions to fixing something like this?
Have some additional code to have multer rotate it according to the orientation data and re-save it?
const upload = multer({ storage: multer.diskStorage({
destination: function (req, file, cb) {
cb(null, avatar_path);
},
filename: function (req, file, cb) {
var ext = require('path').extname(file.originalname);
ext = ext.length>1 ? ext : "." + require('mime').extension(file.mimetype);
require('crypto').pseudoRandomBytes(16, function (err, raw) {
cb(null, (err ? undefined : raw.toString('hex') ) + ext);
});
}
})});
app.post('/upload', upload.single('avatar'), function(req,res) {
.....
});