Denis
Denis

Reputation: 1

How to stylize text with PHP using GD/Imagick?

I use imagettftext() function to add a caption to the image: example Background and captions are separate.

How could I apply the style similar to this one, is it possible with Imagick? I need to create the 3D effect for the letters. required style

I was trying to use and combine letters' images, but I think it's not a good solution. Thanks!

Upvotes: 0

Views: 663

Answers (2)

fmw42
fmw42

Reputation: 53071

If you are willing to use PHP exec(), you can call my Unix Bash Imagemagick script, texteffect2 at my web site http://www.fmwconcepts.com/imagemagick/index.html. It will do bevel and other effects. Here is the script command for doing a bevel:

texteffect2 -t "bevel" -e bevel -s plain -f Ubuntu-Bold -p 200 -c red -bg none result.png

[![enter image description here][1]][1]
-t is the text you want to use
-e is the effect you want
-s is whether to make it plain or add an outline
-f is the font name or font file
-p is the point size for the font
-c is the text color
-bg is the background color (none means transparent)

Here is the basic Imagemagick code to do the bevel effect:

convert -background none -font Ubuntu-Bold \
-pointsize 200 -fill "red" -gravity west label:"BEVEL" \
\( +clone -alpha Extract -write mpr:alpha -blur 0x8 -shade 135x30 \
-auto-level -function polynomial 3.5,-5.05,2.05,0.25 \
mpr:alpha -compose copy_opacity -composite \) \
-compose Hardlight -composite result.png

I do not know Imagick that well. So you might look here https://www.php.net/manual/en/book.imagick.php for the Imagick equivalents or perhaps someone else who uses Imagick can convert it for you.

Upvotes: 1

Martin Zeitler
Martin Zeitler

Reputation: 76689

the method is called Imagick::embossImage, where the text should be a separate layer, before merging the layers for output. just try to manually produce the desired effect with GIMP2, then you know the steps required to get there. the gimp-imagemagick plugin also appears useful for testing.

Upvotes: 0

Related Questions