Simple Example of Image Upload (watermarking, thumbnails, and remote storage)

Source: Internet
Author: User

Simple Example of Image Upload (watermarking, thumbnails, and remote storage) (applied to 51aspx.com)
The source code: http://51aspx.com/CV/ImageUpload
Today, I saw the message sent by xiongeee.ArticleUse the fileupload control to upload images, automatically generate thumbnails, and automatically generate watermarks with text and images

I think that the function of automatically saving remote images may be more practical. I wrote one myself if I found a lot on the Internet and it was incomplete.

Write a test to implement the following functions:

A practical example of uploading images
Image Upload: Create a thumbnail and add a text watermark.
51aspx.png: watermark image
Remote Image Capturing (save to local) supports JPG, GIF, BMP, and PNG
After the image is captured, it is automatically named after auto + date + Original Name
Enter the remote image address (HTML supported)

Here, only the remote saving part is posted.CodeFor other parts, please download the attachment and read it. It is a complete small example. Many people may think it is a good dish, but I think it is helpful to most people and I hope you will give more criticism and guidance.

1 // Automatically save remote Images
2
3 WebClient Client =   New WebClient ();
4 // Standby REG:
5 RegEx Reg =   New RegEx ( " IMG [^>] *? SRC \ s * = \ s *(? :\ " ( ? < 1 > [ ^ \ " ] *) \ " | ' (? <1> [^ \ ' ] * ) ' ) ", Regexoptions. ignorecase );
6 Matchcollection m = Reg. Matches (textbox1.text );
7
8 Foreach (Match math In M)
9 {
10 String Imgurl = Math. Groups [ 1 ]. Value;
11 // Add yymmdd to the original image name and upload it
12 RegEx regname =   New RegEx ( @" \ W + .(? : JPG | GIF | BMP | PNG) " , Regexoptions. ignorecase );
13
14 String Strnewimgname = Datetime. Now. tow.datestring (). Replace ( " - " , "" ) + Regname. Match (imgurl). tostring ();
15
16 Try
17 {
18 // Save image
19 Client. downloadfile (imgurl, server. mappath ( " Imgupload/auto/ "   + Strnewimgname ));
20
21 }
22 Catch
23 {
24}
25 Finally
26 {
27
28}
29
30 Client. Dispose ();
31 }
32
33

Download full source http://51aspx.com/CV/ImageUpload

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.