int width = 0;
int height = 0;
//
var webClient = new System.Net.WebClient();
byte[] image = webClient.DownloadData("http://static.livedemo00.template-help.com/wt_38438/images/page4_img2b.jpg");
//
//byte[] image = FileUpload1.FileBytes;
Int32.TryParse("100", out width);
Int32.TryParse("100", out height);
ImageHandler imageHandler = new ImageHandler();
bool maintainAR = true;
//calling CreateThumbnail Method to create thumb images
//it returns Bitmap Image.
Bitmap bmp = imageHandler.CreateThumbnail(image, maintainAR, width, height);
if (bmp != null)
{
//creating a file name with guid.
string fileName = Guid.NewGuid().ToString() + ".jpg";
//saving in current root folder.
bmp.Save(Server.MapPath(fileName));
//set image controls ImageUrl to saved Image, this is to view the thumbnail image
Image1.ImageUrl = fileName;
}
else
{
//exception part
if (imageHandler.havException)
{
Response.Write(imageHandler.ExceptionMessage);
}
}
Wednesday, March 28, 2012
Make image proportionately small from url link asp.net
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment