Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Used to Create Thumb of a given Image
Author:
Vimal Lakhera
E-mail:
Click to e-mail author
Website:
http://geocities.com/vimallakhera
Submitted:
9/17/2005
Version:
ASP.NET 1.1
Compatibility:
ASP.NET 1.0, ASP.NET 1.1
Category:
Graphics
Views:
12614
Used to Create Thumb of a given Image. Code is in C#. ///
/// Used to Create Thumb of a given Image ///
///
Location of a given Image ///
Location to save Thumb Image ///
Checking and saving Image with appropriate Extension ///
Width of ThumbNail ///
Height of ThumbNail
Declarations:
'none
Code:
public void CreateThumbImage(string strFromPath,string strToPath, string strExt,string RelWidth,string RelHeight) { try { System.Drawing.Image image = System.Drawing.Image.FromFile(strFromPath); // generate thumbnail System.Drawing.Image thumbImage = image.GetThumbnailImage(Convert.ToInt32(RelWidth),Convert.ToInt32(RelHeight),null,IntPtr.Zero); image.Dispose(); // save thumbnail if(strExt.ToString().ToUpper().Equals(".JPEG")) { thumbImage.Save(strToPath, ImageFormat.Jpeg); } if(strExt.ToString().ToUpper().Equals(".GIF")) { thumbImage.Save(strToPath, ImageFormat.Gif); } if(strExt.ToString().ToUpper().Equals(".PNG")) { thumbImage.Save(strToPath, ImageFormat.Png); } if(strExt.ToString().ToUpper().Equals(".TIFF")) { thumbImage.Save(strToPath, ImageFormat.Tiff); } if(strExt.ToString().ToUpper().Equals(".BMP")) { thumbImage.Save(strToPath, ImageFormat.Bmp); } if(strExt.ToString().ToUpper().Equals(".JPG")) { thumbImage.Save(strToPath, ImageFormat.Jpeg); } } catch { } }
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement