Loving ImageMagick - having great fun creating some dynamic stuff with PHP.
I am, of course, stuck on something and I hope you can help.
Basically I have a background image to which I am wanting to place some text, but the text has various effects.
Normally, these are done manually in PhotoShop, so I am trying to create a similar experience from PS.
Now, although using PHP, mod_php is not supported on my server, so I have to use php-cgi: it will be command driven.
I basically want the text beveled (inner and outer), with a drop shadow.
The basic text has a stroke and a fill.
I'm having some trouble getting the shadow to work correctly - I tried to create the text and shadow seperately on a transparent background, but I need the shadow to work on the main image background (being a bit translucent if you like).
Where I am at the moment is:
Create Main text on transparent back.
Create text shadow on transparent back.
Merge shadow onto main image. <--- the shadow is not right on the main image when using -blur feature on the shadow.
Merge main text onto main image.
I'm guessing there is an easier way to do what I want to do... any suggestions?
edit -----------------------------------------------------------------------------------------------------------
I thought I would strip out the commands from the PHP for clarity.
Code: Select all
mogrify -font myfont.TTF -pointsize 24 -fill '#ffffff' -stroke '#999999' -strokewidth 0.5 -annotate 0x0-3-3 '". $text . "' -gravity center temptransfile.png
mogrify -bevel -w 10 -f inner -i hard -s 5 temptransfile.png
mogrify -font myfont.TTF -pointsize 24 -fill '#000000' -annotate -1+1 '". $text. "' -blur 0x10 -gravity center temptransfileshad.png
convert " . $passedImg . " -modulate 100,100," . $hue . " -quality 100 -density 288 tempfile.png
composite -gravity center temptransfileshad.png tempfile.png tempfile2.png
composite -gravity center temptransfile.png tempfile2.png tempfile3.png
Here is what I have so far:
Code: Select all
<?php
$text = "hello world"
$hue = "100"
//Copy transparent image to a temp file.
copy("images/trans_01.png","temptransfile.png");
//Add text to copy of transparent image.
$convert="/usr/bin/mogrify -font myfont.TTF -pointsize 24 -fill '#ffffff' -stroke '#999999' -strokewidth 0.5 -annotate 0x0-3-3 '". $text . "' -gravity center temptransfile.png";
exec ($convert);
print "<br>NAME MAIN<br><img src=temptransfile.png>"; //Show current output.
//BEVEL text - doing this on previous line makes text not appear for some reason.
$convert="/usr/bin/mogrify -bevel -w 10 -f inner -i hard -s 5 temptransfile.png";
exec ($convert);
print "<br>BEVEL<br><img src=temptransfile.png>"; //Show current output.
//SHADOW - Copy transparent file again, and create a shadow effect.
copy("images/trans_01.png","temptransfileshad.png");
$convert="/usr/bin/mogrify -font myfont.TTF -pointsize 24 -fill '#000000' -annotate -1+1 '". $text. "' -blur 0x10 -gravity center temptransfileshad.png";
exec ($convert);
print "<br>NAME SHADOW<br><img src=temptransfileshad.png>"; //Show current output.
//BACKGROUND - Copy master file to temporary working file, change hue of working file as needed.
copy($passedImg,"tempfile.png");
$convert="/usr/bin/convert " . $passedImg . " -modulate 100,100," . $hue . " -quality 100 -density 288 tempfile.png";
exec ($convert);
print "<br>BACK<br><img src=tempfile.png>"; //Show current output.
//MERGE SHADOW - Put shadow on background.
$convert="/usr/bin/composite -gravity center temptransfileshad.png tempfile.png tempfile2.png";
exec ($convert);
//MERGE MAIN TEXT - Put main text on the background.
$convert="/usr/bin/composite -gravity center temptransfile.png tempfile2.png tempfile3.png";
exec ($convert);
print "<br>FINAL<br><img src=tempfile3.png>";
?>