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?".
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
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.
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.
<?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");
?>
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
<?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
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.
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.
The grayscale is then applied using 'overlay' compositing, so that a pure mid-tone gray becomes transparent, leaving just the highlights and shadow effects.