[Original] common ASP. NET functions-generating image thumbnails

Source: Internet
Author: User

In the past two days, I thought about how to sort out the small functions in my previous projects and give them to everyone! Upon your suggestion, I decided to addSource code, But the sourceCodeNot all of them are written by me. Some are from books, some are from the Internet, some are from open-source projects, and some are inconsistent with my own code. That is the previous example!

Source code: smallimg.rar

Upload a 800*1000 image and generate different thumbnails respectively.

Namespace:
Using system. IO;

Core code:
System. Drawing. image. getthumbnailimageabort callb = NULL;

Try
{
// Save to the specified folder
File1.postedfile. saveas (server. mappath ("/Semir/imgsides/") + sidepath );
Myimage = system. Drawing. image. fromfile (server. mappath ("/Semir/imgsides/") + sidepath );
// Save the large image (original image)
Newimage = myimage. getthumbnailimage (800,100 0, callb, new system. intptr ());
Newimage. Save (server. mappath ("/Semir/imgsides/") + "big" + sidepath );
// Save the Graph
Newimage = myimage. getthumbnailimage (400,500, callb, new system. intptr ());
Newimage. Save (server. mappath ("/Semir/imgsides/") + "Middle" + sidepath );

// The image size of a single dress
Newimage = myimage. getthumbnailimage (255,319, callb, new system. intptr ());
Newimage. Save (server. mappath ("/Semir/imgsides/") + "singleimage" + sidepath );

// Save the thumbnail
Newimage = myimage. getthumbnailimage (115,144, callb, new system. intptr ());
Newimage. Save (server. mappath ("/Semir/imgsides/") + "small" + sidepath );
// Save the minimal Graph
Newimage = myimage. getthumbnailimage (45, 56, callb, new system. intptr ());
Newimage. Save (server. mappath ("/Semir/imgsides/") + "Dinky" + sidepath );

myimage. dispose ();
newimage. dispose ();
// be sure to release it; otherwise, the process is occupied
}< br> catch (exception ex)
{< br> response. write (ex. tostring ();
}

Related Article

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.