Last post Aug 03, 2010 02:58 PM by zoggling
Aug 02, 2010 11:35 AM|zoggling|LINK
I have an upload control on my ASP page, to allow users to upload photos to a folder in the web site directory. After uploading, I would like the site to automatically generate thumbnails from these images (so that the thumbnails can be displayed in a gallery
page, rather than the high-quality images themselves). Can anyone provide some code/references that will do this?
My requirements are:
- Needs to be a part of my web application (no Windows.Forms solutions please!)
- Generate one thumbnail per uploaded image
- Thumbnail must have same ratio as original
- Source files will be .bmp, .jpg and possibly .tif and .png
- Potentially a means to adjust resolution/size of generated thumbnails
- Potentially run in the background, so that the user can continue to navigate through the website and/or upload further images.
My page has VB.NET code-behind.
Many thanks in advance!
generate thumbnail files uploaded images
Aug 03, 2010 12:38 AM|stanly|LINK
Aug 03, 2010 01:38 AM|dotNetViper|LINK
Also see the link below
Aug 03, 2010 01:47 AM|sunilyadav165|LINK
I have created something similar look at the link below.
hope it helps.
Aug 03, 2010 02:41 AM|Vipindas|LINK
public void ResizeStream(int imageSize, Stream filePath, string outputPath)
var image = Image.FromStream(filePath);
int thumbnailSize = imageSize;
int newWidth, newHeight;
if (image.Width > image.Height)
newWidth = thumbnailSize;
newHeight = image.Height * thumbnailSize / image.Width;
newWidth = image.Width * thumbnailSize / image.Height;
newHeight = thumbnailSize;
var thumbnailBitmap = new Bitmap(newWidth, newHeight);
var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
then call resize image function as
ResizeImage(400, File1.FileContent, path);
Aug 03, 2010 02:58 PM|zoggling|LINK
Thank you for your replies everyone! This has given me a good resource of possibilities to work from. Thanks again!