略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Imagick::drawImage

2024-04-29

Imagick::drawImage

(PECL imagick 2, PECL imagick 3)

Imagick::drawImage把 ImagickDraw 对象渲染到当前图片上

说明

Imagick::drawImage(ImagickDraw $draw): bool

把 ImagickDraw 对象渲染到当前图片上。

参数

draw

被渲染到图片上的 ImagickDraw 对象(在经过各种绘画操作之后的 ImagickDraw 对象)

返回值

成功时返回 true

add a noteadd a note

User Contributed Notes 2 notes

up
3
blah at blub dot com
12 years ago
If your imagick lib begins to say: "Non-conforming drawing primitive...", it could be that your locale are not correctly set. please locate all your setlocale and kill them temporary so you could check it that would solve the problem.
up
-2
sualk at lednew dot de
13 years ago
the ImagickDraw (v 2.2.0) seems to disharmonise with PHP-GTK2 (v 2.0.1).

The rendering of an ImagickDraw object on the current image fails (resp. results in a flat image without drawings), if php_gtk2.so is loaded.

Code to reproduce the failure:

#!/usr/bin/php5
<?php
dl
("php_gtk2.so"); // comment this for a second try

$string = "Hello world!";

$im = new Imagick();
$draw = new ImagickDraw();

$draw->setFillColor(new ImagickPixel('blue'));

$draw->setFontSize(28);

$metrix = $im->queryFontMetrics($draw, $string);

$draw->annotation(0,25,$string);

$im->newImage($metrix['textWidth'],$metrix['textHeight'], new ImagickPixel('white'));
$im->drawImage($draw);
$im->borderImage(new ImagickPixel('black'), 1, 1);
$im->setImageFormat('png');

$im->writeImage("./test.png");
?>

官方地址:https://www.php.net/manual/en/imagick.drawimage.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3