Page 1 of 1

Watermark sunken emboss text?

Posted: 2008-08-09T11:21:24-07:00
by acctman
does anyone know how to do a sunken emboss transparent text watermark with IM using php or shell cmd?

something like this but instead of the text being raised it sunken
Image

Re: Watermark sunken emboss text?

Posted: 2008-08-09T12:59:29-07:00
by Bonzo
There may be something here:
http://www.imagemagick.org/Usage/fonts/

Re: Watermark sunken emboss text?

Posted: 2008-08-09T18:05:46-07:00
by acctman
so is it better to make a transparent .png image with the text rather than having IM use a TTF file and put the text on the image? The problem i'd see with using a .png is sizing the png to fit the image

Re: Watermark sunken emboss text?

Posted: 2008-08-10T00:24:17-07:00
by Bonzo
You are using an extra layer in your example you posted as well.

Using php you could resize the text especialy if it is the same every time as you can use getimagesize( ) and use the sizes in that to vary the size of your watermark.

Re: Watermark sunken emboss text?

Posted: 2008-08-10T12:45:45-07:00
by acctman
is there a workable example that you can show me? I'm not sure if I should use a .png or text .ttf font

Re: Watermark sunken emboss text?

Posted: 2008-08-11T00:35:40-07:00
by anthony
IM can do layered images just as shown. It is very straight forward and examples are given in annotating images, watermarking
http://www.imagemagick.org/Usage/annotating/#wmark_text

By drawing the text you can still give good size control to the watermarking text. However pre-prepared fixed sized watermarks can contain any text or logo, and will be faster, especially if applying them to lots of images.

Re: Watermark sunken emboss text?

Posted: 2008-08-11T05:48:08-07:00
by Bonzo
Example:

Code: Select all

<?php

$size = getimagesize("input.jpg");

// Size for watermark
$width = $size[0]*.9;
$height = $size[0]*.25;

$cmd = "-size {$width}x{$height} -background none -font Utopia-bold -fill white ".
" -gravity center caption:\"Copyright of Rubblewebs\" -shade 240x40";

echo $cmd;

// Create the watermark
exec("convert $cmd font.png ");

exec("composite -watermark 30% -gravity south font.png input.jpg watermark.png");

?>
Image

Re: Watermark sunken emboss text?

Posted: 2008-08-11T17:01:57-07:00
by acctman
Bonzo wrote:Example:

Code: Select all

<?php

$size = getimagesize("input.jpg");

// Size for watermark
$width = $size[0]*.9;
$height = $size[0]*.25;

$cmd = "-size {$width}x{$height} -background none -font Utopia-bold -fill white ".
" -gravity center caption:\"Copyright of Rubblewebs\" -shade 240x40";

echo $cmd;

// Create the watermark
exec("convert $cmd font.png ");

exec("composite -watermark 30% -gravity south font.png input.jpg watermark.png");

?>
Image

questions the font.png and watermark.png are auto created right? or am I supplying those files? I see where you have the caption: line with the watermark text. But then you have a create watermark where you have font.png and then in the last line you use the font.png and a watermark.png?

input.jpg is the image, where are the two other .png files

Re: Watermark sunken emboss text?

Posted: 2008-08-12T02:39:07-07:00
by Bonzo
More comments added:

Code: Select all

<?php
// Find the size of the image to add the watermark to
$size = getimagesize("input.jpg");

// Size for watermark - $size[0] = the width of the image to watermark
// Calculate some sizes to use for the box containing the text.
// In this case the image width x 0.9 and the image width x 0.25
$width = $size[0]*.9;
$height = $size[0]*.25;

// Set a variable containing the information to create the transparent text.
// Using the variables above for the canvas size and adding the embossed effect with the -shade.
$cmd = "-size {$width}x{$height} -background none -font Utopia-bold -fill white ".
" -gravity center caption:\"Copyright of Rubblewebs\" -shade 240x40";

// Just to confirm the variable $cmd contains what I think it should, coment out when code working OK
echo $cmd;

// This takes the variable above and creates the first image called font.png
exec("convert $cmd font.png ");

// This then puts the watermark text and puts it on the image
exec("composite -watermark 30% -gravity south font.png input.jpg watermark.png");

?>


You only have 3 images - The image to watermark supplied by you. The transparent image containing the text created by the code. The final watermarked image created by the code.

Delete font.png if you want; it will be overwritten everytime the code is run

Re: Watermark sunken emboss text?

Posted: 2008-08-12T11:24:35-07:00
by acctman
thanks for all the help. one more quick question, is it possible to make the text sunken? just and idea, if it cant be done its ok.

Re: Watermark sunken emboss text?

Posted: 2008-08-12T11:37:33-07:00
by Bonzo
It is sunken !

I suppose its how your eye views it; I do not think there is any easy way. This uses the -shade 240x40 operator and you could try different values and see what you get.

Re: Watermark sunken emboss text?

Posted: 2008-08-13T17:11:58-07:00
by anthony
See IM Examples, Transforms, Shade Usage
http://www.imagemagick.org/Usage/transform/#shade
for examples of how various angles look.

For a 'sunken effect' use 275x40 OR -45x40 OR use a 'black on white' as the shade image. Any of these three methods will make a sunken image.

Re: Watermark sunken emboss text?

Posted: 2008-08-23T00:19:24-07:00
by acctman
anthony wrote:See IM Examples, Transforms, Shade Usage
http://www.imagemagick.org/Usage/transform/#shade
for examples of how various angles look.

For a 'sunken effect' use 275x40 OR -45x40 OR use a 'black on white' as the shade image. Any of these three methods will make a sunken image.
is there anyway of getting this sunken effect
Image

Re: Watermark sunken emboss text?

Posted: 2008-08-23T10:54:43-07:00
by fmw42
Don't know, but you have watermarked an image that is backwards (can't read the text on the shirt) :wink:

Re: Watermark sunken emboss text?

Posted: 2008-08-24T18:38:44-07:00
by anthony
The text image is basically like what has already been exampled. However before 'shade' was applied the text was smoothed to give it a more 'curved' shading effect.

See IM Examples, http://www.imagemagick.org/Usage/transform/#shade
and especially the later section http://www.imagemagick.org/Usage/transf ... de_overlay

The grayscale is then applied using 'overlay' compositing, so that a pure mid-tone gray becomes transparent, leaving just the highlights and shadow effects.