C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Creating Thumbnail of images in ASP.NET


Posted Date: 21 Jun 2008    Resource Type: Articles    Category: Web Applications

Posted By: pradeep       Member Level: Silver
Rating:     Points: 10



This code sample shows how to create thumbnail of an image on the fly:

1) first create a folder name Image
2) add two more folder in image folder thumbnails and Sthumbnails

Sample code:

public class utility
{
public utility()
{
//
// TODO: Add constructor logic here
//
}
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;
thumbWidth = image.Width;
thumbHeight = image.Height;

if (image.Height > image.Width && image.Height > size)
{
thumbHeight = size;
decimal tWidth = (w / h) * thumbHeight;
thumbWidth = Convert.ToInt32(tWidth);
}
else
{
if (image.Width > size)
{
thumbWidth = size;
decimal tHeight = (h / w) * thumbWidth;
thumbHeight = Convert.ToInt32(tHeight);
}
}
// create the actual thumbnail image
System.Drawing.Image thumbnailImage;
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;
}
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Thumbnails  .  Thumbnail  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: PayPal Integration sample using C#
Previous Resource: Sending Email in ASP.NET 2.0
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use