public static void C_Thumbnails(int size, string FilePath, string ThumbPath)
{
// create an image object, using the filename we just retrieved
System.Drawing.Image image = System.Drawing.Image.FromFile(FilePath);
try
{
int thumbHeight, thumbWidth;
decimal h = image.Height;
decimal w = image.Width;
if (image.Height > image.Width)
{
thumbHeight = size;
decimal tWidth = (w / h) * thumbHeight;
thumbWidth = Convert.ToInt32(tWidth);
}
else
{
thumbWidth = size;
decimal tHeight = (h / w) * thumbWidth;
thumbHeight = Convert.ToInt32(tHeight);
}
// create the actual thumbnail image
System.Drawing.Image thumbnailImage = image.GetThumbnailImage(thumbWidth, thumbHeight, null, IntPtr.Zero);
image.Dispose();
// put the image into the memory stream
thumbnailImage.Save(ThumbPath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (Exception ex)
{
image.Dispose();
throw ex;
}
-
ShriKrishna Bhardwaj , With ASP.Net, SQL Server, Javascript
1 comment:
Hi..
System.Drawing.Image image = System.Drawing.Image.FromFile(FilePath);
It gets null..no file.
can u plz show me the calling procedure for it..
specifically what is to be sent in filepath and thumbpath parameters.
Thankyou!
Post a Comment