I have been uploading image using asp.net image upload control and turns out that when i upload image whose size is over 1MB it flip over i.e it rotates 90 degree automatically but not for the case when size is below 1MB. Here is the code that I have used until now.
string path = "ImagePath goes here";
string fileName = image.jpg;
fileupload.SaveAs(path + fileName); //here the original size image is saved
Stream strm = fileupload.PostedFile.InputStream;
double scaleFactor = 0.5;
var image = Image.FromStream(strm);
var newWidth = (int)(image.Width * scaleFactor);
var newHeight = (int)(image.Height * scaleFactor);
var thumbnailImg = new Bitmap(newWidth, newHeight);
var thumbGraph = Graphics.FromImage(thumbnailImg);
thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbGraph.DrawImage(image, imageRectangle);
thumbnailImg.Save(path + fileName, image.RawFormat); //After saving this I get the resized image but image flipover 90 degree
This is the code that I have done until now. Please help me guys to overcome this issue.