Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply watermark with text / image using GraphicsMagick

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)

like image 880
Giannis Avatar asked Jan 08 '14 13:01

Giannis


People also ask

How do I watermark an image in Imagemagick?

To add a watermark to photo in-place you can use the same addresss for both input. jpg and output. jpg and the original photo will be replaced with the watermarked version. Make sure to have a backup before modifying images in place.


1 Answers

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.

like image 166
Moogle Avatar answered Sep 27 '22 21:09

Moogle