ImageMagick PHP-扭曲文本并在图像上添加注释

ImageMagick PHP-扭曲文本并在图像上添加注释,php,imagemagick,imagick,Php,Imagemagick,Imagick,是否可以使用ImageMagick(PHP)扭曲文本并在图像上对其进行注释?或者我必须从文本创建一个图像,扭曲它,然后粘贴到我的基础图像上 我有一个咖啡杯,想添加文字。我想在我的文字上加一个小弧线,在我的杯子上有一个三维的外观 我试过使用拱形字体: 但是在我的代码示例中,我无法让它工作,因为文本是$draw=new ImagickDraw();我不能扭曲它或使用拱形字体。我的整个图像总是被扭曲,因为这种扭曲只适用于像$image=new Imagick('original/'.$id..jpg

是否可以使用ImageMagick(PHP)扭曲文本并在图像上对其进行注释?或者我必须从文本创建一个图像,扭曲它,然后粘贴到我的基础图像上

我有一个咖啡杯,想添加文字。我想在我的文字上加一个小弧线,在我的杯子上有一个三维的外观

我试过使用拱形字体:

但是在我的代码示例中,我无法让它工作,因为文本是$draw=new ImagickDraw();我不能扭曲它或使用拱形字体。我的整个图像总是被扭曲,因为这种扭曲只适用于像$image=new Imagick('original/'.$id..jpg')这样的图像

非常感谢您的任何提示或建议。我需要一种有点凹拱的字体,如本例所示:

我不能让它在PHP中工作

$fontpath = 'fonts/';
$id = $_REQUEST["id"];
$text1 = $_REQUEST['text1'];
$text2 = $_REQUEST['text2'];

$fontname1 = $_REQUEST['fontname1'];
$fontname2 = $_REQUEST['fontname2'];

$x_coordinate1 = $_REQUEST['x_coordinate1'];
$x_coordinate2 = $_REQUEST['x_coordinate2'];

$y_coordinate1 = $_REQUEST['y_coordinate1'];
$y_coordinate2 = $_REQUEST['y_coordinate2'];

$pointsize1 = $_REQUEST['pointsize1'];
$pointsize2 = $_REQUEST['pointsize2'];

$fill1 = $_REQUEST['fill1'];
$fill2 = $_REQUEST['fill2'];

$stroke1 = $_REQUEST['stroke1'];
$stroke2 = $_REQUEST['stroke2'];

/* Create some objects */
//$image = new Imagick();
$draw = new ImagickDraw();

/* New image */
$image = new Imagick('original/'.$id.'.jpg');

/* Text color */
$draw->setFillColor($fill1);

/* Font properties */
$draw->setFont($fontpath.$fontname1);
$draw->setFontSize( $pointsize1 );

/* Create text */
/* Center is important */
$draw->setGravity (Imagick::GRAVITY_CENTER);
$image->annotateImage($draw, $x_coordinate1, $y_coordinate1, 0, $text1);

/* Text2 color */
$draw->setFillColor($fill2);

/* Font2 properties */
$draw->setFont($fontpath.$fontname2);
$draw->setFontSize( $pointsize2 );

$draw->setGravity (Imagick::GRAVITY_CENTER);


$image->annotateImage($draw, $x_coordinate2, $y_coordinate2, 0, $text2);

/* Give image a format */
$image->setImageFormat('jpg');

/* Output the image with headers */
header('Content-type: image/jpg');
echo $image;

fmw42的评论最适合我的问题。我将文本创建为透明背景的图像,然后扭曲,最后在另一个图像上合成

您必须将文本创建为具有透明背景的图像,然后对其进行扭曲。然后将扭曲的文本图像合成到背景图像上。见和。也可以通过PHP exec()使用我的texteffect bash unix shell脚本。请参见续:有关拱和弧,请参见。在透明背景上创建文本图像,并像这些示例中那样扭曲它。将结果合成到背景图像上。好的,谢谢。所以我需要从我的文本中创建另一个图像。我希望可以避免这种情况。如果您使用的是Unix系统,您可能希望在我的网站上浏览我的bash shell脚本texteffect。或者查看我上面指定的链接。Imagemagick不会在路径上创建文本。所以你必须创建一个文本图像,然后扭曲它,最后在你的背景图像上合成它。