In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how ASP.NET uploads pictures and generates thumbnails with copyright information, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.
The code is as follows:
Void Page_Load (Object sender, EventArgs e) {if (! Page.IsPostBack) {ImgPreview.Visible=false;}} void GetThumbnailImage (int width,int height,string strInfo,int left,int right) {string file= "Uploads/" + uploadFile.PostedFile.FileName.Substring (uploadFile.PostedFile.FileName.LastIndexOf ('\\) + 1); string newfile= "Uploads/" + uploadFile.PostedFile.FileName.Substring (uploadFile.PostedFile.FileName.LastIndexOf ('\') + 1) + ".jpg"; string strAdd=strInfo System.Drawing.Image oldimage = System.Drawing.Image.FromFile (Server.MapPath (file)); System.Drawing.Image thumbnailImage = oldimage.GetThumbnailImage (width, height,new System.Drawing.Image.GetThumbnailImageAbort (ThumbnailCallback), IntPtr.Zero); Response.Clear (); Bitmap output=new Bitmap (thumbnailImage); Graphics g=Graphics.FromImage (output); g.DrawString (strAdd,new Font ("Courier New", 14), new SolidBrush (Color.Red), left,right); output.Save (Server.MapPath (newfile), System.Drawing.Imaging.ImageFormat.Jpeg) Response.ContentType = "image/gif"; ImgPreview.Visible=true; ImgPreview.ImageUrl=newfile;} bool ThumbnailCallback () {return true;} void Button_Click (object sender, EventArgs e) {int width,height,left,right; string strAddInfo=txtAddInfo.Text; width=Int32.Parse (txtWidth.Text); height=Int32.Parse (txtHeight.Text); left=Int32.Parse (txtLeft.Text); right=Int32.Parse (txtRight.Text); if (! (uploadFile.PostedFile.ContentLength > 0)) {lblErrInfo.Text= "No file selected" } else {string path = Server.MapPath (". / Uploads/" + uploadFile.PostedFile.FileName.Substring (uploadFile.PostedFile.FileName.LastIndexOf ('\') + 1)); if (File.Exists (path)) {lblErrInfo.Text= "already has a file with the same name";} else {uploadFile.PostedFile.SaveAs (path); GetThumbnailImage (width,height,strAddInfo,left,right);}
Width:100 height:150
Add Information: AspxBoy.Com
Information location: left:10 right:135
The above is all the contents of the article "how ASP.NET uploads pictures and generates thumbnails with copyright information". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.