Watermark sunken emboss 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
acctman

Watermark sunken emboss text?

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark sunken emboss text?

Post by Bonzo »

There may be something here:
http://www.imagemagick.org/Usage/fonts/
acctman

Re: Watermark sunken emboss text?

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark sunken emboss text?

Post 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.
acctman

Re: Watermark sunken emboss text?

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Watermark sunken emboss text?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark sunken emboss text?

Post 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
acctman

Re: Watermark sunken emboss text?

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark sunken emboss text?

Post 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
acctman

Re: Watermark sunken emboss text?

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Watermark sunken emboss text?

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Watermark sunken emboss text?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
acctman

Re: Watermark sunken emboss text?

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermark sunken emboss text?

Post by fmw42 »

Don't know, but you have watermarked an image that is backwards (can't read the text on the shirt) :wink:
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Watermark sunken emboss text?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply