如何使用GD / Imagick使用PHP来设置文本样式?

问题描述 投票:0回答:2

我使用imagettftext()函数为图像添加标题:example背景和标题是分开的。

我怎么能应用类似于这个的风格,是否可以使用Imagick?我需要为字母创建3D效果。 required style

我试图使用和组合字母的图像,但我认为这不是一个好的解决方案。谢谢!

php text imagick
2个回答
1
投票

如果你愿意使用PHP exec(),你可以在我的网站http://www.fmwconcepts.com/imagemagick/index.html上调用我的Unix Bash Imagemagick脚本texteffect2。它会做斜角和其他效果。这是用于执行斜角的脚本命令:

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

enter image description here

-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)

以下是执行斜角效果的基本Imagemagick代码:

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

我不太清楚Imagick。所以你可能会在这里看看http://us3.php.net/manual/en/book.imagick.php的Imagick等价物或者使用Imagick的其他人可以为你转换它。


0
投票

该方法称为Imagick::embossImage,其中文本应该是一个单独的图层,然后合并图层以进行输出。只是尝试用GIMP2手动产生所需的效果,然后你知道到达那里所需的步骤。 gimp-imagemagick插件似乎也可用于测试。

© www.soinside.com 2019 - 2024. All rights reserved.