Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Add Watermark text on Image

Posted by Viral Sarvaiya on September 18, 2009

step 1. upload the image file
step 2. save the image and get the filename with the full the path where the image file will store.


dim pathname as string
// this "pathname" contains path with filename of the uploaded file with fileupload control.

Dim ImgStamp As New Bitmap(pathname)
Dim g As Graphics = Graphics.FromImage(ImgStamp)
g.SmoothingMode = SmoothingMode.AntiAlias
Dim y As Integer = 0
y = ImgStamp.Height - 85
Dim FSize As Double = ImgStamp.Height
Dim FWSize As Double = ImgStamp.Width
If FSize > 640 Then
'Set Position
FSize = ImgStamp.Width * 28 / 640
y = ImgStamp.Height / 1.1
ElseIf FWSize < 426 Then
'Set Position
FSize = ImgStamp.Width * 28 / 640
y = ImgStamp.Height / 1.1
Else
'Set Position
FSize = ImgStamp.Width * 28 / 640
y = ImgStamp.Height / 1.1
End If
g.DrawString("Put Water mark text here", New Font("font name", CType(FSize, Integer), FontStyle.Regular), Brushes.Azure, New Point(1, y))
ImgStamp.Save(path & imgName)

change the numbers according to the requirement, where you want the watermark text.

enjoy coding…..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: