string ImagePath = Server.MapPath(".")+"\\Upload\\NewsImage\\" + Utility.GenerateGUID() + "-Image"; if (fuImage.PostedFile != null) { fuImage.PostedFile.SaveAs(ImagePath); fuImage.Dispose(); string d = Utility.GetThumbnailImage(ImagePath, 100, 100,true); } public static string GetThumbnailImage(string path,int x,int y,bool DeleteAfterSave) { // Create the in-memory bitmap where you will draw the image. Bitmap image = new Bitmap(x, y); Graphics g = Graphics.FromImage(image); // Load the file data. System.Drawing.Image thumbnail = System.Drawing.Image.FromFile(path); // Draw the thumbnail. g.DrawImage(thumbnail, 0, 0, x, y); // Render the image. string NewPath = path +"-small.jpg"; image.Save(NewPath, ImageFormat.Jpeg); g.Dispose(); image.Dispose(); if (DeleteAfterSave == true) { System.IO.File.Delete(path); } return path; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)