Quick Watermark
The Code: watermark.aspx
<%@ Page Explicit="True" Language="VB" Debug="True" %>
<%@ Import Namespace="system.drawing" %>
<%@ Import Namespace="system.drawing.imaging" %>
<%@ Import Namespace="system.drawing.drawing2d" %>
<%@ Import Namespace="system.io" %>
<script runat="server">
dim Filename as String
dim Width, Height, shadowSize as Integer
dim Bitmap as system.drawing.bitmap
dim ImgFormat as ImageFormat
dim Img as System.Drawing.Image
Dim baseMap as Bitmap
dim top, left as Integer
sub CreateGraphic()
Dim letterBrush as SolidBrush = new SolidBrush(Color.FromArgb(50, 255, 255, 255))
Dim shadowBrush as SolidBrush = new SolidBrush(Color.FromArgb(50, 0, 0, 0))
Dim fontTitle as Font = new Font("tahoma", 20, FontStyle.Bold)
Filename = Request.QueryString("filename")
Filename = server.mappath(Filename)
ImgFormat = ImageFormat.jpeg : response.contenttype="image/jpeg" ' Default=jpeg '
Img = system.drawing.image.FromFile(Filename)
Width = Img.Width
Height = Img.Height
baseMap = new Bitmap(Width,Height)
Dim myGraphic as Graphics = Graphics.FromImage(baseMap)
with myGraphic
.DrawImage(Img, 0,0, Width,Height)
.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
.DrawString("LABS.INSERT-TITLE.COM", fontTitle, shadowBrush, 5, 60)
.DrawString("LABS.INSERT-TITLE.COM", fontTitle, letterBrush, 7, 62)
end with
Img.dispose()
end sub
</script>
<%
CreateGraphic
baseMap.Save(Response.OutputStream, ImageFormat.JPEG)
baseMap.dispose()
Img = Nothing
response.end
%>
</script>
Usage
Example