Dear All,
I have found a function on the net to resize my images, however, when i am debugging it, it is giving me an exception.
This is the function:-
private static void GenerateImage(string sPhysicalPath,string sOrgFileName,ImageFormat oFormat, int image_width, int image_height)
{
try
{
System.Drawing.Image oImg = System.Drawing.Image.FromFile(sPhysicalPath + sOrgFileName);
System.Drawing.Image oThumbNail = new Bitmap(image_width, image_height, oImg.PixelFormat);
Graphics oGraphic = Graphics.FromImage(oThumbNail);
oGraphic.CompositingQuality = CompositingQuality.HighQuality ;
oGraphic.SmoothingMode = SmoothingMode.HighQuality ;
oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic ;
Rectangle oRectangle = new Rectangle(0, 0, image_width, image_height);
oGraphic.DrawImage(oImg, oRectangle);
oThumbNail.Save(sPhysicalPath + sOrgFileName,oFormat);
oImg.Dispose();
}
catch (Exception ex)
{
//exception
StringBuilder strImgExc = new StringBuilder();
strImgExc.Append(ex.Message);
}
}
Now these are the values when i debug:-
sPhysicalPath = @"c:\inetpub\wwwroot\ImageConsole\Images_Folder\"
sOrgFileName = "test.jpg"
ex (System Exception) = {@"c:\inetpub\wwwroot\ImageConsole\Images_Folder\test.jpg" }
Can anybody tell me what am i doing wrong? Does the sPhysicalPath has to be different?
Thanks for your help and time
Johann