Click here to Skip to main content
15,891,567 members
Articles / Web Development / ASP.NET

Program for Watermarking an Image

Rate me:
Please Sign up or sign in to vote.
3.94/5 (23 votes)
31 Mar 2010CPOL3 min read 66.1K   3.5K   76  
To uniquely identify the images from our storage, we watermark them with some text (usually company / portal name)
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Browse an image of type .jpg, .gif, .png, or .bmp. Must be less than or equal to 10MB in size:<br />
        <asp:FileUpload ID="fpImage" runat="server" />
        <asp:RequiredFieldValidator ID="reqImage" Display="Dynamic" ControlToValidate="fpImage" style="font:12px verdana;color:Red;vertical-align:middle;" Text="(Required)" runat="server"></asp:RequiredFieldValidator>
        <asp:CustomValidator ID="cvImageType" Display="Dynamic" ControlToValidate="fpImage" OnServerValidate="cvImageType_Validate" style="font:12px verdana;color:Red;vertical-align:middle;" Text="&nbsp;(Image must be any of these types: .jpg, .gif, .png, .bmp, .tif)" runat="server"></asp:CustomValidator>
        <asp:CustomValidator ID="cvImageSize" Display="Dynamic" ControlToValidate="fpImage" OnServerValidate="cvImageSize_Validate" style="font:12px verdana;color:Red;vertical-align:middle;" Text="&nbsp;(Image size must not exceed by 10MB.)" runat="server"></asp:CustomValidator>
        <br /><br />
        <asp:Button ID="btnResults" Text="Show Result" OnClick="btnResults_OnClick" runat="server" />
        <br /><br />
        <table cellpadding="0" cellspacing="0" border="0" style="width:800px">
            <tr>
                <td style="width:50%;padding-right:10px;text-align:center;">
                    <h3>Original Image</h3>
                    <asp:Image ID="imgOriginal" Width="380px" Height="380px" runat="server" />
                </td>
                <td style="width:50%;padding-left:10px;text-align:center;">
                    <h3>Resultant Image</h3>
                    <asp:Image ID="imgResult" Width="380px" Height="380px" runat="server" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Cherisys Technologies
India India
Senior Software Professional with 13+ years of experience in web/desktop applications development.

Comments and Discussions