/// <summary> /// Roates a Gallery image /// </summary> /// <param name="member"></param> /// <param name="WebPhotoID"></param> /// <param name="RootPath"></param> /// <returns></returns> public static bool RotateGalleryImage(Member member, string WebPhotoID, string RootPath, int Rotation) { // seems a bit overcomplicated but you cannot save to an image that is open as its locked.. so open it from a file // stream and then dispose the filestream //try //{ Photo photo = Photo.GetPhotoByWebPhotoIDWithJoin(WebPhotoID); string FullPath = RootPath + member.NickName; string LargeFullPath = FullPath + @"\plrge\" + photo.PhotoResourceFile.FileName; string MediumFullPath = FullPath + @"\pmed\" + photo.PhotoResourceFile.FileName; string ThumbFullPath = FullPath + @"\pthmb\" + photo.PhotoResourceFile.FileName; FileStream fsLarge = new FileStream(LargeFullPath, FileMode.Open); Image LargeImage = Bitmap.FromStream(fsLarge); fsLarge.Close(); fsLarge.Dispose(); if (Rotation == 1) { LargeImage.RotateFlip(RotateFlipType.Rotate90FlipNone); } else if (Rotation == 2) { LargeImage.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (Rotation == 3) { LargeImage.RotateFlip(RotateFlipType.Rotate270FlipNone); } SaveToDiskRelativePath(LargeImage, LargeFullPath); //resize medium and save System.Drawing.Image MediumImage = Photo.Resize480x480(LargeImage); SaveToDiskRelativePath(MediumImage, MediumFullPath); //resize thumbnail and save System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage); SaveToDiskRelativePath(ThumbnailImage, ThumbFullPath); LargeImage.Dispose(); return(true); //} //catch (Exception ex) //{ // return false; //} }