#region "Image Resize to 250* 250"
try
{
// Get the path of the original Image
string OriginalImageUrlPath="~/Testimage/TestImage.jpg"
string displayedImg = Server.MapPath(OriginalImageUrlPath);
FileInfo fi = new FileInfo(displayedImg);
//fi.Name="TestImage.jpg";
// Get the path of the Thumb folder
string ThumbnailImagepath = (@"~/Testimage/Thumbnail" + "/") + fi.Name;
string displayedImgThumb = Server.MapPath(ThumbnailImagepath );
// Get the original image file name
string imgFileName = System.IO.Path.GetFileName(displayedImg);
//imgFileName="TestImage.jpg";
// Load original image
System.Drawing.Image myimg = System.Drawing.Image.FromFile(displayedImg);
// Get the thumbnail 250X 250px
myimg = myimg.GetThumbnailImage(250, 250, null, IntPtr.Zero);
// Save the new thumbnail image
myimg.Save(displayedImgThumb, myimg.RawFormat);
Console.WriteLine("Success");
}
catch(Exception ex)
{
Console.WriteLine("Fail");
}
#endregion
try
{
// Get the path of the original Image
string OriginalImageUrlPath="~/Testimage/TestImage.jpg"
string displayedImg = Server.MapPath(OriginalImageUrlPath);
FileInfo fi = new FileInfo(displayedImg);
//fi.Name="TestImage.jpg";
// Get the path of the Thumb folder
string ThumbnailImagepath = (@"~/Testimage/Thumbnail" + "/") + fi.Name;
string displayedImgThumb = Server.MapPath(ThumbnailImagepath );
// Get the original image file name
string imgFileName = System.IO.Path.GetFileName(displayedImg);
//imgFileName="TestImage.jpg";
// Load original image
System.Drawing.Image myimg = System.Drawing.Image.FromFile(displayedImg);
// Get the thumbnail 250X 250px
myimg = myimg.GetThumbnailImage(250, 250, null, IntPtr.Zero);
// Save the new thumbnail image
myimg.Save(displayedImgThumb, myimg.RawFormat);
Console.WriteLine("Success");
}
catch(Exception ex)
{
Console.WriteLine("Fail");
}
#endregion
No comments:
Post a Comment