Reputation: 7216
Hey guys, I have an image that I'm downloading from the internet and need to resize it to 1/4 of it's size while preserving its aspect ratio. Any ideas on how to do this easiest?
WebRequest requestPic = WebRequest.Create(imageURL);
WebResponse responsePic = requestPic.GetResponse();
Image webImage = Image.FromStream(responsePic.GetResponseStream());
// Need to resize image here
Random rand = new Random();
string imageName = string.Format("{0:x}{1:x}", DateTime.Now.Ticks, rand.Next(0, 60400000));
if (webImage != null)
{
webImage.Save(string.Format("c:\\{0}.jpg", imageName));
}
Thank you!
Upvotes: 2
Views: 1408
Reputation: 7340
Image thumb = image.GetThumbnailImage(image.Width / 2, image.Height / 2, null, IntPtr.Zero);
image.Dispose();
Upvotes: 4