HttpPostedFile hpf = context.Request.Files[i] as HttpPostedFile; Image img = Image.FromStream(hpf.InputStream); try { foreach (var prop in img.PropertyItems) { if (prop.Id == 0x0112) //value of EXIF { var orientation = img.GetPropertyItem(prop.Id).Value[0]; switch (orientation) { case 1: // No rotation required. break; case 2: img.RotateFlip(RotateFlipType.RotateNoneFlipX); break; case 3: img.RotateFlip(RotateFlipType.Rotate180FlipNone); break; } // This EXIF data is now invalid and should be removed. img.RemovePropertyItem(0x0112); } } } catch (Exception ex) { string error = ex.Message.ToString(); } string strImageName = System.Web.HttpContext.Current.Request.QueryString["ID"].ToString() + "-" + strPhotoCounter + ".jpg"; //----------------This block works------------- Image img_converted = (Image)img.Clone(); img_converted.Save(strOriginalPath + strImageName); img_converted.Dispose(); img.Dispose(); //---------------- But this is not------------------ hpf.SaveAs(strOriginalPath + strImageName); img.Dispose();
It work if it done "Clone" but not with "HttpPostedFile.SaveAs" why this is so??
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)