Watermark of images

Posted by Venkat | Labels: ,

We are going to discuss about watermarking the image , the importance of doing the watermark is protected and not to be redistributed , Suppose if you take some online gallery images , like arts,some site which selling photos are restricted his site image. They might be not to allow users to save image by right click on image , or saving the web page.


'Creating Dynamic Watermark on image
Dim objImage As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("~/images/" & "Management.jpg"))
'From File
Dim height As Integer = objImage.Height
'Actual image width
Dim width As Integer = objImage.Width
'Actual image height
Dim bitmapimage As New System.Drawing.Bitmap(objImage, width, height)
' create bitmap with same size of Actual image
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bitmapimage)
'Creates a System.Drawing.Color structure from the four ARGB component
'(alpha, red, green, and blue) values. Although this method allows a 32-bit value
' to be passed for each component, the value of each component is limited to 8 bits.
'create Brush
Dim brush As New SolidBrush(Color.FromArgb(113, 255, 255, 255))
'Adding watermark text on image
g.DrawString("Copywright", New Font("Arial", 18, System.Drawing.FontStyle.Bold), brush, 0, 100)
'save image with Watermark image/picture
'bitmapimage.Save("watermark-image.jpg"); //if u want to save image
Response.ContentType = "image/jpeg"
bitmapimage.Save(Server.MapPath("~/images/Copy.jpg"), ImageFormat.Jpeg)
bitmapimage.Dispose()
objImage.Dispose()

0 comments:

Post a Comment

Thanks for the Comments.

PayOffers.in