How to add the copyright text to the uploaded picture

Source: Internet
Author: User
Tags file size split
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>





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.