Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to develop one online application, which user enter any word (fname,lname) itself on images.
and also that image can be download his/her computers.

e.g
Like online form application.
user fill up online form it self and then his/her download that form.


But,I want fill up the form on image.


Thanks,
Posted

Please following the links to find the solution.May they will help you.

http://www.daniweb.com/web-development/aspnet/threads/105229/add-watermark-in-image[^]

Watermark image on page print in ASP.NET[^]

Thanks
 
Share this answer
 
two effective ways to do this.. You can create a gif file that is transparent except for your watermark and create it the same size, or close to, of the default image. Then on your page, set the background of a div to the default image, and the size of the div to the size of the default image. Then inside the div, place the of the watermark. This stops most people from copying and saving your pictures.

Anther way is to have it done dynamically at runtime. This creates a krap load of resources on your server and will always as long as any image is called. I would recommend staying away from it.

The way that I do it is that I upload the picture to my server through a website, save a temp of it, open the temp, resize and then add a watermark to it (just text at the moment).. then save it to the name and directory wanted. I do this both for thumbnails and main images. I'll give you a resize function and a watermark function that you might want to use.

You need these namespaces:

C#
<![CDATA[<%@ import Namespace="System.IO" %>
<![CDATA[<%@ import Namespace="System.Drawing.Imaging" %>
<![CDATA[<%@ import Namespace="System.Drawing" %>
<![CDATA[<%@ import Namespace="System.Drawing.Drawing2D" %>
resize function:

Function generateThumbnail(ByVal newWidth As Integer, ByVal strFileName As String, ByVal newStrFileName As String)
  Dim bmp As Bitmap
  Dim newHeight As Integer
  Dim resized As Bitmap
  Dim FilePath As String = Server.MapPath("/images/")
  bmp = System.Drawing.Image.FromFile(FilePath & strFileName & ".jpg")
  newHeight = (newWidth/bmp.width)*bmp.Height
  resized = new Bitmap(newWidth,newHeight)
  newStrFileName = FilePath & newStrFileName & ".jpg"
  
  Dim g as Graphics = Graphics.FromImage(resized)
  g.SmoothingMode = SmoothingMode.HighQuality
  g.CompositingQuality = CompositingQuality.HighQuality
  g.InterpolationMode = InterpolationMode.High
  g.DrawImage(bmp, new Rectangle(0,0,resized.Width,resized.Height),0,0,bmp.Width,bmp.Height,GraphicsUnit.Pixel)
  g.Dispose()
  resized.Save(newStrFileName,ImageFormat.Jpeg)
  bmp.dispose()
End Function
watermark function:

Function watermark(ByVal strFileName As String, ByVal newStrFileName As String)
  Dim FilePath As String = Server.MapPath("/images/")
  Dim bmp As Bitmap = System.Drawing.Image.FromFile(FilePath & strFileName & ".jpg")
  Dim strWatermark As String = "WATERMARK TEXT"
  Dim canvas As Graphics = Graphics.FromImage(resized)
  Dim StringSizeF As SizeF, DesiredWidth As Single, wmFont As Font, RequiredFontSize As Single, Ratio As Single
  newStrFileName = FilePath & newStrFileName & ".jpg"
  wmFont = New Font("Verdana", 6, FontStyle.Bold)
  DesiredWidth = bmp.Width * .75
  StringSizeF = canvas.MeasureString(strWatermark, wmFont)
  Ratio = StringSizeF.Width / wmFont.SizeInPoints
  RequiredFontSize = DesiredWidth / Ratio
  wmFont = New Font("Verdana", RequiredFontSize, FontStyle.Bold)
  canvas.DrawString(strWatermark, wmFont, New SolidBrush(Color.Beige), 0, 0)
  canvas.DrawString(strWatermark, wmFont, New SolidBrush(Color.FromArgb(128, 0, 0, 0)), 2, 2)
  canvas.DrawString(strWatermark, wmFont, New SolidBrush(Color.FromArgb(128, 255, 255, 255)), 0, 0)
  canvas.DrawString(strWatermark, wmFont, New SolidBrush(Color.FromArgb(128, 0, 0, 0)), 2, 2)
  canvas.DrawString(strWatermark, wmFont, New SolidBrush(Color.FromArgb(128, 255, 255, 255)), 0, 0)
  bmp.SetResolution(96, 96)
  bmp.Save(newStrFileName,ImageFormat.Jpeg)
  canvas.dispose()
  bmp.dispose()
End Function

Now these functions I have edited before I put on here, so if there's a flaw let me know as I haven't had time to test them. Anyway, you need to save your uploaded image first, or at least know the location of the ones you want to watermark or resize. An example on how to use these are:

''resize
''if you wish to have the ".jpg" within the function command, remove it from
''within the function and you can have "resizeme.jpg" and "resized.jpg"
generateThumbnail(100,"resizeme","resized")
''watermark
''if you wish to have the ".jpg" within the function command, remove it from
''within the function and you can have "watermarkme.jpg" and "watermarked.jpg"
watermark("watermarkme","watermarked")
These functions only do JPEGS, so if you try another file format, it will fail on you.
 
Share this answer
 
v2
Comments
AshishChaudha 16-Oct-12 6:48am    
Code copied from

http://www.daniweb.com/web-development/aspnet/threads/105229/add-watermark-in-image

Please give refrence to the link from where you got the solution.
[no name] 16-Oct-12 6:51am    
there is no need to give link, wht matter is the solution.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900