How to add the copyright text to the uploaded picture
Last Update:2017-02-28
Source: Internet
Author: User
Upload
Many times need to upload a picture of the user to add copyright or some other additional text information, how to achieve such a function, below a simple implementation of the example, play a role.
<%@ Page language= "C #" debug= "true" trace= "true"%>
<%@ Import namespace= "System.IO"%>
<%@ Import namespace= "System.Drawing"%>
<%@ Import namespace= "System.Drawing.Imaging"%>
<script runat =server>
void Uploadbtn_click (Object sender, EventArgs e) {
String filename;
String filename1;
String[] filename2;
int q;
Filename=uploadfile.postedfile.filename;
Filename2=filename. Split (new char[] {'} ');
Q=filename2. GetUpperBound (0);
FILENAME1=FILENAME2[Q];
Dis. text= "Upload filename:" +filename1+ "<br>";
UploadFile.PostedFile.SaveAs (Server.MapPath (filename1));
Imageeditor.visible = true;
Dis. text+= "File size:" +uploadfile.postedfile.contentlength+ "number of bytes";
image1.src=filename1;
}
void Updatebtn_click (Object sender, EventArgs e) {
String filename1;
FILENAME1=IMAGE1.SRC;
System.Drawing.Image Image = System.Drawing.Image.FromFile (Server.MapPath (filename1));
System.Drawing.Image newimage = new Bitmap (Image. Width, image. Height, Pixelformat.format32bpprgb);
Graphics g = graphics.fromimage (newimage);
G.drawimage (image,0,0,image. Width,image. Height);
Font f = new Font (FontType.SelectedItem.Text, Int32.Parse (FontSize.SelectedItem.Text));
Brush B = new SolidBrush (color.red);
g.DrawString (Caption.text, F, B, 10, 140);
G.dispose ();
System.Drawing.Image thumbimage = newimage. Getthumbnailimage (Int32.Parse (width.text), Int32.Parse
(Height.text), null,0);
Image. Dispose ();
Thumbimage.save (Server.MapPath (filename1), imageformat.jpeg);
image1.src=filename1;
Caption.text= "";
}
</script>
<body>
<asp:label id= "Dis" runat=server/>
<form enctype= "Multipart/form-data" runat=server>
Select Upload file: <input id= "UploadFile" Type=file runat=server>
<asp:button text= "Upload me!" runat=server/>
<asp:panel id= "Imageeditor" Visible=false runat=server>
Image width: <asp:textbox id= "width" runat=server/>
Image height: <asp:textbox id= "height" runat=server/> <br>
Text title: <asp:textbox id= "Caption" runat=server/>
Title Font size: <asp:dropdownlist id= "FontSize" runat=server>
<asp:listitem>14</asp:listitem>
<asp:listitem>18</asp:listitem>
<asp:listitem>26</asp:listitem>
<asp:listitem>36</asp:listitem>
<asp:listitem>48</asp:listitem>
<asp:listitem>62</asp:listitem>
</asp:dropdownlist>
Title font: <asp:dropdownlist id= "Fonttype" runat=server>
<asp:listitem> Bold </asp:listitem>
<asp:listitem> Imitation </asp:listitem>
<asp:listitem> Official Script </asp:listitem>
<asp:listitem> Regular Script </asp:listitem>
<asp:listitem> Choi Wan </asp:listitem>
<asp:listitem> New Wei </asp:listitem>
</asp:dropdownlist>
<asp:button text= "Update Image" runat=server/>
</asp:panel>
</form>
</body>
Many times need to upload a picture of the user to add copyright or some other additional text information, how to achieve such a function, below a simple implementation of the example, play a role.
<%@ Page language= "C #" debug= "true" trace= "true"%>
<%@ Import namespace= "System.IO"%>
<%@ Import namespace= "System.Drawing"%>
<%@ Import namespace= "System.Drawing.Imaging"%>
<script runat =server>
void Uploadbtn_click (Object sender, EventArgs e) {
String filename;
String filename1;
String[] filename2;
int q;
Filename=uploadfile.postedfile.filename;
Filename2=filename. Split (new char[] {'} ');
Q=filename2. GetUpperBound (0);
FILENAME1=FILENAME2[Q];
Dis. text= "Upload filename:" +filename1+ "<br>";
UploadFile.PostedFile.SaveAs (Server.MapPath (filename1));
Imageeditor.visible = true;
Dis. text+= "File size:" +uploadfile.postedfile.contentlength+ "number of bytes";
image1.src=filename1;
}
void Updatebtn_click (Object sender, EventArgs e) {
String filename1;
FILENAME1=IMAGE1.SRC;
System.Drawing.Image Image = System.Drawing.Image.FromFile (Server.MapPath (filename1));
System.Drawing.Image newimage = new Bitmap (Image. Width, image. Height, Pixelformat.format32bpprgb);
Graphics g = graphics.fromimage (newimage);
G.drawimage (image,0,0,image. Width,image. Height);
Font f = new Font (FontType.SelectedItem.Text, Int32.Parse (FontSize.SelectedItem.Text));
Brush B = new SolidBrush (color.red);
g.DrawString (Caption.text, F, B, 10, 140);
G.dispose ();
System.Drawing.Image thumbimage = newimage. Getthumbnailimage (Int32.Parse (width.text), Int32.Parse
(Height.text), null,0);
Image. Dispose ();
Thumbimage.save (Server.MapPath (filename1), imageformat.jpeg);
image1.src=filename1;
Caption.text= "";
}
</script>
<body>
<asp:label id= "Dis" runat=server/>
<form enctype= "Multipart/form-data" runat=server>
Select Upload file: <input id= "UploadFile" Type=file runat=server>
<asp:button text= "Upload me!" runat=server/>
<asp:panel id= "Imageeditor" Visible=false runat=server>
Image width: <asp:textbox id= "width" runat=server/>
Image height: <asp:textbox id= "height" runat=server/> <br>
Text title: <asp:textbox id= "Caption" runat=server/>
Title Font size: <asp:dropdownlist id= "FontSize" runat=server>
<asp:listitem>14</asp:listitem>
<asp:listitem>18</asp:listitem>
<asp:listitem>26</asp:listitem>
<asp:listitem>36</asp:listitem>
<asp:listitem>48</asp:listitem>
<asp:listitem>62</asp:listitem>
</asp:dropdownlist>
Title font: <asp:dropdownlist id= "Fonttype" runat=server>
<asp:listitem> Bold </asp:listitem>
<asp:listitem> Imitation </asp:listitem>
<asp:listitem> Official Script </asp:listitem>
<asp:listitem> Regular Script </asp:listitem>
<asp:listitem> Choi Wan </asp:listitem>
<asp:listitem> New Wei </asp:listitem>
</asp:dropdownlist>
<asp:button text= "Update Image" runat=server/>
</asp:panel>
</form>
</body>