Scale down the image by proportion (scale down the height by width)

Source: Internet
Author: User
/// <Summary>
/// Scale down the image in proportion (scale down the height and scale down the image in width)
/// </Summary>
/// <Param name = "imagemap"> image displayed on the page </param>
/// <Param name = "ImagePath"> image virtual path </param>
/// <Param name = "widthsize"> width of the cropped image </param>
/// <Param name = "server"> server on this page </param>
Public void imagesize (system. Web. UI. webcontrols. Image Imagemap, string ImagePath, int widthsize, system. Web. httpserverutility server)
{
System. Drawing. Image IMG = system. Drawing. image. fromfile (server. mappath (ImagePath ));
Int imgwidth = IMG. width;
Int imgheight = IMG. height;
Imagemap. imageurl = ImagePath;
If (imgwidth> widthsize)
{
Imagemap. width = widthsize;
Imagemap. Height = widthsize * imgheight/imgwidth;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.