Page 1 of 1

text watermark change sizes depending on image it's on

Posted: 2013-03-19T11:19:16-07:00
by pommeverte
Hi guys,

I'm hitting a bit of a wall. I need to add a text watermark to images, however I don't know the size of these images so I end up with tet that isn't the appropriate size (tiny) on some images.
The command I use is:

Code: Select all

convert 'in.tif'[0] -profile 'AdobeRGB1998.icc' -resize 6150400@\> -background white -flatten -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 'this is a test' -stroke none -fill white -annotate 0 'this is a test' 'out.jpg'
Like I mentioned earlier, I need to find a way of resizing this watermark along with the image.

Thanks in advance for your help. I could probably resize the watermark using size $(convert etc...)x$(convert etc..) or something of the likes, but some images are really big and I would like to save computer ressources wherever possible

Re: text watermark change sizes depending on image it's on

Posted: 2013-03-19T12:19:29-07:00
by fmw42
create an image of your text with transparent background by using label: to fit the image width. Then composite the text image over your background image.

See
http://www.imagemagick.org/Usage/text/#label_bestfit
http://www.imagemagick.org/Usage/layers/#convert

Re: text watermark change sizes depending on image it's on

Posted: 2013-03-20T04:01:09-07:00
by pommeverte
But I am resizing the background image using an area size, so how do I know what size to give my label?
I'd also rather not make a label the size of the original file if I could help it as it would be a waste of ressources. Given the amount of conversions our server has to make this is important for us

Re: text watermark change sizes depending on image it's on

Posted: 2013-03-20T16:01:14-07:00
by fmw42
resize your background, get its size and then create and overlay the text image via label:

Unfortunately, that means multiple commands.

Or pre-compute the size of the resized image first, then create the label to that size and overlay. You will either know the resize width and/or height or know what percent factor you use. So either way, you can compute the width and/or height of the resized image ahead of time.

Otherwise, do everything at the full image size, overlay the text image and then resize.

I am not sure there is any other way.

Re: text watermark change sizes depending on image it's on

Posted: 2013-03-20T18:15:33-07:00
by pommeverte
Is there any way I could pipe the resized image and get it's resized height/width on the fly? If not I guess I'll have to compute height/width, I was kind of using area size to avoid it but hey.

Re: text watermark change sizes depending on image it's on

Posted: 2013-03-20T18:40:24-07:00
by fmw42
pommeverte wrote:Is there any way I could pipe the resized image and get it's resized height/width on the fly? If not I guess I'll have to compute height/width, I was kind of using area size to avoid it but hey.
I do not believe that is possible in IM 6. But later in IM 7 I think that will be more feasible.

Unless you are using -resize with @ for file size, you can easily pre-compute the resized image width and height

Re: text watermark change sizes depending on image it's on

Posted: 2013-12-03T14:01:26-07:00
by xeviousx
Resurrecting this post from the dead,

I have attempted to run this code on a windows machine with the latest IM but the dissolve does not work (the watermark is fully opaque)

the code i am using is

convert in.tif -size 1555x2560 xc:none -gravity center -fill grey -font Arial \
-pointsize 227.25 -annotate 300x300+0+0 "Testing" -background none \
-compose dissolve -define compose:args=30,100 -composite out.tif

what if anything is wrong?

If i create a png image with the below code and composite it in a seperate process then it works just fine but i would like to get it in one go.

convert -size 1555x2560 xc:none -gravity center -fill grey -font Arial \
-pointsize 227.25 -annotate 300x300+0+0 "Testing" -background none watermark.png

Thanks

Re: text watermark change sizes depending on image it's on

Posted: 2013-12-03T14:37:47-07:00
by snibgo
convert in.tif -size 1555x2560 xc:none -gravity center -fill grey -font Arial \
-pointsize 227.25 -annotate 300x300+0+0 "Testing" -background none \
-compose dissolve -define compose:args=30,100 -composite out.tif
Eek. That code will:

read in.tif
create a second image 1555x2560 with transparent background
annotate both images
dissolve them together.

You need parentheses, something like this:
convert in.tif \( -size 1555x2560 xc:none -gravity center -fill grey -font Arial \
-pointsize 227.25 -annotate 300x300+0+0 "Testing" \) -background none \
-compose dissolve -define compose:args=30,100 -composite out.tif
Now the annotate will only be done to the second image.