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 ();
}