Based on your help file code, I would like to figure out how to create two thumbnails (one <=100 pixels wide and another <=700 pixels wide) and maintain the aspect ratio (constraint).
string target = Server.MapPath("~/Images/Logos/"); |
Image.GetThumbnailImageAbort thumbnailImageAbortDelegate = |
new Image.GetThumbnailImageAbort(ThumbnailCallback); |
foreach (UploadedFile file in RadUpload1.UploadedFiles) |
{ |
file.SaveAs(Path.Combine(target, file.GetName())); |
using (Bitmap originalImage = new Bitmap(file.InputStream)) |
{ |
//You can implement additional logic to compute |
// the width / height according your requirements |
int width = originalImage.Width / 2; |
int height = originalImage.Height / 2; |
using (Image thumbnail = |
originalImage.GetThumbnailImage(width, height, thumbnailImageAbortDelegate, IntPtr.Zero)) |
{ |
string thumbnailFileName = Path.Combine(target, |
string.Format("{0}_thumb{1}", file.GetNameWithoutExtension(), file.GetExtension())); |
thumbnail.Save(thumbnailFileName); |
} |