add watermark in image

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 84
Reputation: nandhinijp is an unknown quantity at this point 
Solved Threads: 4
nandhinijp nandhinijp is offline Offline
Junior Poster in Training

Re: add watermark in image

 
0
  #11
Jan 29th, 2008
Its fine working.Thanks.I have one more doubt regarding watermark text size.I have same size images.In one image,watermark text is large font.In another one image small font size.I want watermark text as standard format,size and also according to image size.
below code for text size.
SizeF textSize = graphic.MeasureString(watermark, myFont);

int x =100;
int y= 100;
PointF pointF = new PointF(x, y);
graphic.DrawString(watermark, myFont, brush, pointF);
x += Convert.ToInt32(textSize.Width);
y += Convert.ToInt32(textSize.Height);

If u want please verify my earlier attachment.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: add watermark in image

 
0
  #12
Jan 29th, 2008
You need to set the font size depending on the size of the image. Now how long is your watermark, and how far across the image do you want it to be? In my example, it is set at 70% of the image's size. So if this was my images' size:
  1. ---------------------------
  2. | |
  3. | |
  4. |WaterMarkText 70% |
  5. | |
  6. |Water Mark 50% |
  7. ---------------------------
Therefore, if you wish your watermark to be 70% of the picture width, you need to divide your pictures width by the ratio.

Look at my earlier example. It is always set to 75% of the picture. So if the picture is 6000 pixels in width, my text will always take up 4500 pixels. If it is only 100 pixels in width, it will take up 75 pixels.
Last edited by SheSaidImaPregy; Jan 29th, 2008 at 10:47 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 84
Reputation: nandhinijp is an unknown quantity at this point 
Solved Threads: 4
nandhinijp nandhinijp is offline Offline
Junior Poster in Training

Re: add watermark in image

 
0
  #13
Jan 30th, 2008
gdfgdsfgdfgdf
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 84
Reputation: nandhinijp is an unknown quantity at this point 
Solved Threads: 4
nandhinijp nandhinijp is offline Offline
Junior Poster in Training

Re: add watermark in image

 
0
  #14
Jan 30th, 2008
Watermark text size related to image resolution.If image resolution is 100 means text size is small if it is >300 text size too large.can we change the image resolution at the upload time. or can we set text doesnt relate with resolution.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: add watermark in image

 
0
  #15
Jan 30th, 2008
It should relate to the resolution, it should relate to the width of the image.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: add watermark in image

 
0
  #16
Jan 30th, 2008
Oh I see what you're saying. Yes you can set it to a certain size period. Keep this in mind though that if the picture is small, your watermark may "run off" the picture. Instead of setting the watermark text to a resized font size, just set the font size!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 84
Reputation: nandhinijp is an unknown quantity at this point 
Solved Threads: 4
nandhinijp nandhinijp is offline Offline
Junior Poster in Training

Re: add watermark in image

 
0
  #17
Jan 30th, 2008
Without text size problem Its working good in local.If i upload files it doesnt work in site.I think problem in specifying the image path that is

Image image = Image.FromFile(context.Request.PhysicalPath);

what is the exact path specification instead of this.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 84
Reputation: nandhinijp is an unknown quantity at this point 
Solved Threads: 4
nandhinijp nandhinijp is offline Offline
Junior Poster in Training

Re: add watermark in image

 
0
  #18
Jan 30th, 2008
I didnt set watermark text to a resized font size,I just set the font size!

Font myFont = new Font("Arial", 18);
SolidBrush brush = new SolidBrush(Color.FromArgb(80, Color.White));
At run time it takes like that.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: add watermark in image

 
0
  #19
Jan 30th, 2008
can I see the graphics? Take a screen shot of a smaller one and a larger one so I see the scope of your problem. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 84
Reputation: nandhinijp is an unknown quantity at this point 
Solved Threads: 4
nandhinijp nandhinijp is offline Offline
Junior Poster in Training

Re: add watermark in image

 
0
  #20
Jan 31st, 2008
The first image(bird) has a resolution 300.second one 100.I think In that class there is no relation between text size and resolution.
Last edited by nandhinijp; Jan 31st, 2008 at 2:05 am.
Attached Thumbnails
72031016bird1_showimage[1].jpg   20649968Aishwarya-Rai-2[1]_showimage[1].jpg  
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC