0

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.

  • I have resolved the image flipping issue using this [link](https://stackoverflow.com/questions/46410452/system-drawing-graphics-drawimage-rotates-picture-taken-from-ios-to-90-degre). But could not decrease the file size as after using the ImageHelper class it increases my file size like 3 times the original size can you help me please – Sanjay Chaudhary May 05 '22 at 11:32

0 Answers0