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.