开发者

Transparent text with wideImage lib?

开发者 https://www.devze.com 2023-02-16 23:28 出处:网络
I am using http://wideimage.sourceforge.net/ w开发者_如何转开发ith PHP and I would like to write text on image which will be transparent in about 50%. Is it possible?Yes, it is possible, but requires

I am using http://wideimage.sourceforge.net/ w开发者_如何转开发ith PHP and I would like to write text on image which will be transparent in about 50%. Is it possible?


Yes, it is possible, but requires you to retrieve the TrueColor version of the image:

$image = $image->asTrueColor();

Once that is done, you can simply do the following to write text with 50% alpha transparency:

$color = $image->allocateColorAlpha(255, 255, 255, 63);
$canvas = $image->getCanvas();
$canvas->useFont('path/to/font.ttf', 16, $color);
$canvas->writeText('right', 'bottom', 'Hello, world!');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号