如何更改使用PHP Imagick的newPseudoImage函数绘制的标题的颜色? [英] How do I change the color of a caption drawn with PHP Imagick's newPseudoImage function?
本文介绍了如何更改使用PHP Imagick的newPseudoImage函数绘制的标题的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 Imagick :: newPseudoImage
函数创建带有标题的图像,如下所示:
I am creating an image with a caption using the Imagick::newPseudoImage
function as follows:
$txt = new Imagick();
$txt->setFont("templates/fonts/Gloria.ttf");
$txt->setGravity(imagick::GRAVITY_CENTER);
$txt->newPseudoImage( $image_width, $image_height, "caption:" . $text );
这会画一个黑色标题。我想自定义此标题的颜色。我知道还有其他使用Imagick绘制文本的方法。我需要使用带有标题的 newPseudoImage
而不是其他方法,因为它会自动换行并调整文本大小以适合给定的矩形。
This draws a black caption. I want to customize the color of this caption. I know there are other methods of drawing text with Imagick. I need to use the newPseudoImage
with caption instead of these other methods because it automatically wraps and sizes the text to fit in a given rectangle.
推荐答案
您可以使用 colorizeImage 。我希望这可以帮到你:
You can use colorizeImage. I hope this can help you:
$im = new Imagick();
$background = new ImagickPixel('none');
$im->setBackgroundColor($background);
$im->setFont("somefont.ttf");
$im->setpointsize(72);
$im->setGravity(Imagick::GRAVITY_CENTER);
$im->newPseudoImage(300, 300, "caption:" . "Put your text" );
$im->colorizeImage('#0000b0',1.0);
$im->setImageFormat("png");
header( "Content-Type: image/png" );
echo $im;
这篇关于如何更改使用PHP Imagick的newPseudoImage函数绘制的标题的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文