Watermark with Text

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
PaigeS
Posts: 6
Joined: 2011-07-27T11:34:24-07:00
Authentication code: 8675308

Watermark with Text

Post by PaigeS »

Hi, I'm trying to watermark an image with text, but I'm struggling to get this done. I've read many blogs online, including http://www.imagemagick.org/Usage/annotating/#wmark_text ...but my watermark is just not coming out correctly.
My main problem is that my watermark seems to have a background that is visible (though somewhat lightened) even after the "composite" command...The first command DOES create a watermark. And the second command DOES put the watermark on the image...but I can't get it to look correct...like an embossed/watermarked text on the image...

I'm using ASP.NET, but I'm basically just using a shell command from there.

Here's my code:
convert -size 300x50 xc:grey30 -background transparent -font Arial -pointsize 20 -gravity center -draw "fill white text 1,1 'Tequipment.net' text 0,0 'Tequipment.net' fill black text -1,-1 'Tequipment.net' " +matte WATERMARK_FILE.png

composite -dissolve 50% -gravity south WATERMARK_FILE.png INPUT_IMAGE OUTPUT_IMAGE


I've also tried -watermark 30%, instead of -dissolve 50%, in the composite command...plus MANY OTHER THINGS.
I've tried playing with the first command:
-background none instead of -background transparent
-xc:white and xc:black instead of xc:grey30


Please help! I really need to get this working already.

Thanks in advance!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark with Text

Post by Bonzo »

THis should work:

Code: Select all

convert -size 300x50 xc:none -font Arial -pointsize 20 -gravity center -draw \"fill white text 1,1 'Tequipment.net' text 0,0 'Tequipment.net' fill black text -1,-1 'Tequipment.net' \" WATERMARK_FILE.png

composite -dissolve 50% -gravity south WATERMARK_FILE.png INPUT_IMAGE OUTPUT_IMAGE
I have just noticed that if you put the logo over a transparent part of a png it shows a background.

When you say embossed were you looking to achive this effect?
Image
PaigeS
Posts: 6
Joined: 2011-07-27T11:34:24-07:00
Authentication code: 8675308

Re: Watermark with Text

Post by PaigeS »

Yes, thank you. That worked! Thank you!
Here's a sample: Image

But, I would prefer something prettier like the rubbleheads sample above...Is there any slight modifications to size/font/etc to make my watermark more pleasant and professional? Though I don't want something too big, because I think my company will want it 'tiled.'

Thanks again so much for your quick response!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark with Text

Post by Bonzo »

I am glad it worked and I have some php watermark examples on my site including an example of tiling which you could convert: http://www.rubblewebs.co.uk/imagemagick/watermark.php

There are other watermarking ideas on Anthony's site: http://www.imagemagick.org/Usage/annota ... termarking

If you have any other code questions please post your code between the "Code" tags as as it is easier to read.
Is there any slight modifications to size/font/etc
There are so many options with Imagemagick and it will work with all ttf fonts - you can space the letters more with -kerning to allow for any drop shadows etc.
PaigeS
Posts: 6
Joined: 2011-07-27T11:34:24-07:00
Authentication code: 8675308

Re: Watermark with Text

Post by PaigeS »

Hi, thanks for all your help.

I tried copying the code you have for the nice embossed look in the sample (of the flower) you included above. Here's my code:

Code: Select all

convert -size 450x200 -background none -font Utopia-bold -fill white -gravity center caption:"Tequipment.net" -shade 240x40 WATERMARK_FILE.png
                    
But this is what I'm getting:
(does not look embossed, and not the same font as yours)
Image
PaigeS
Posts: 6
Joined: 2011-07-27T11:34:24-07:00
Authentication code: 8675308

Re: Watermark with Text

Post by PaigeS »

I'm now trying to use the annotate command, since I want my text to be angled & tiled. So, here's what I have:

Code: Select all

convert -size 400x200 xc:none -font Arial -pointsize 30 -kerning 2 -gravity center -fill rgba(0,0,0,0.4) -annotate 315x315+0+0  "Tequipment.net" WATERMARK_FILE.png
                    
And here's the image:
Image

But, i need to be able to use the fill commands like I do with the draw command...

Code: Select all

-draw \"fill white text 1,1 'Tequipment.net' text 0,0 'Tequipment.net' fill black text -1,-1 'Tequipment.net' \"
...so that you can see the watermark over dark images & light images.
But, I don't want it to be QUITE so bold...I really like the embossed look...
PaigeS
Posts: 6
Joined: 2011-07-27T11:34:24-07:00
Authentication code: 8675308

Re: Watermark with Text

Post by PaigeS »

OK, I got it to work to my boss's desire...so no need to answer anything in this post.
Here's my current code for anyone else who's looking at this...

Image

Code: Select all

convert -size 400x200 xc:none -font Arial -pointsize 25 -kerning 1 -gravity center -fill black -annotate 330x330+0+0 "Tequipment.net" -fill white -annotate 330x330+2+2  "Tequipment.net" WATERMARK_FILE.png

composite -dissolve 20% -tile WATERMARK_FILE.png INPUT_FILE OUTPUT_FILE

                    
PaigeS
Posts: 6
Joined: 2011-07-27T11:34:24-07:00
Authentication code: 8675308

Re: Watermark with Text

Post by PaigeS »

Sorry to anyone who's looking at this -- I see I used the same image url each time I played with it...so looking now at the older posts (besides the last one) is not actually how it looked when I commented on it...
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark with Text

Post by Bonzo »

Good result, to use a different font you can use any true type font and you either need to put it in the same folder as your code or provide the path to the font. I think some fonts give better results in this case - probably "chunkier" fonts are best.

To list the fonts imagemagick knows about use either of the codes below depending on your version:

Code: Select all

convert -list font
or
convert -list type
I assume you can run some php code on your server and there is an example of how to get a graphical output of the fonts here: http://www.rubblewebs.co.uk/imagemagick ... /fonts.php
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Watermark with Text

Post by anthony »

It is posible to do the tiling in a single "convert" command. It is just not a simple 'option' at this time.
Tiling with a in-memory image...
http://www.imagemagick.org/Usage/canvas/#tile_memory
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply