When trying to upload images from a mobile device like an iPhone, it's common for the images to appear sideways unless viewed directly in Chrome.
It seems that this issue is related to the image exif orientation data, which Chrome can ignore but other browsers may struggle with.
What are some possible solutions to correct this problem?
Is it feasible to add additional code to Multer that can rotate the image based on the orientation data before saving it again?
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) {
.....
});