Question

I need to be able to apply watermark on an image, using either text or another image. Getting it to work with an image was quite straight forward, using the following command:

gm composite -dissolve 15 -tile logo.png image.jpg wmark_tiled.jpg

Now, I also want to be able to use text for watermarking (in other cases). The only thing that I found close to it, is a command from ImageMagick tutorial which is the following :

convert -size 140x80 xc:none -fill grey -gravity NorthWest -draw "text 10,10 'copyrigh text'" -gravity SouthEast -draw "text 5,15 'copyright text'" miff:- | gm composite -tile - image.jpg copyrightImage.jpg 

Although its not working in GM, and I would rather avoid using pipe as it causes some headaches managing it from Java.

What I thought I could do, is generate an image from a given text, and then use that image as logo.png is used on my first command. Although I cannot find how to generate an image out of text, all I find is putting text on top of an image.

Ideally I will generate a transparent image with the text, and from what I see modifying font/color etc should be quite flexible.

Any suggestions on how to achieve this, or any better solutions are welcome. (I added imagemagick tag as the interfaces are often same/similar)

Was it helpful?

Solution

I'm not sure I fully understand your query, so apologies if I've misunderstood, but are you trying to create a transparent image, with some text in the corner? If so, would this not work?

convert -background transparent -fill grey -font Calibri -size 140x80 -pointsize 14 -gravity southeast label:'copyright text' output.png

Obviously adjusting the font, pointsize, output image name etc. That would create the following:

http://oi42.tinypic.com/14j1bvp.jpg

P.S. that was written for ImageMagick. I don't know how GM differs or whether it would still work.

OTHER TIPS

To be able to get the watermark text into the same image I had to use the -annotate parameter.

So Moogle's code snippet would look like this in my case:

convert original_image.jpg -background transparent -fill grey -font Calibri -size 140x80 -pointsize 14 -gravity southeast -annotate +0+0 'copyright text' output.jpg
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top