略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Imagick::functionImage

2024-12-22

Imagick::functionImage

(PECL imagick 2 >= 2.3.0, PECL imagick 3)

Imagick::functionImageApplies a function on the image

说明

public Imagick::functionImage(int $function, array $arguments, int $channel = Imagick::CHANNEL_DEFAULT): bool

Applies an arithmetic, relational, or logical expression to a pseudo image.

See also » ImageMagick v6 Examples - Image Transformations — Function, Multi-Argument Evaluate

此方法在Imagick基于ImageMagick 6.4.9以上版本编译时可用。

参数

function

Refer to this list of function constants

arguments

Array of arguments to pass to this function.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Create a sinusoidal gradient

<?php
$imagick 
= new Imagick();
$imagick->newPseudoImage(200200'gradient:black-white');
$arguments = array(3, -90);
$imagick->functionImage(Imagick::FUNCTION_SINUSOID$arguments);

header("Content-Type: image/png");
$imagick->setImageFormat("png");
echo 
$imagick->getImageBlob();
?>

以上例程的输出类似于:

Output of create a sinusoidal gradient

示例 #2 Create a gradient from the polynomial (4x^2 - 4x + 1)

<?php
$imagick 
= new Imagick();
$imagick->newPseudoImage(200200'gradient:black-white');
$arguments = array(4, -41);
$imagick->functionImage(Imagick::FUNCTION_POLYNOMIAL$arguments);

header("Content-Type: image/png");
$imagick->setimageformat("png");
echo 
$imagick->getImageBlob();
?>

以上例程的输出类似于:

Output of create a polynomial gradient

示例 #3 Create a complex gradient from the polynomial (4x^2 - 4x^2 + 1) modulated by a sinusoidal gradient

<?php
$imagick1 
= new Imagick();
$imagick1->newPseudoImage(200200'gradient:black-white');
$arguments = array(9, -90);
$imagick1->functionImage(Imagick::FUNCTION_SINUSOID$arguments);

$imagick2 = new Imagick();
$imagick2->newPseudoImage(200200'gradient:black-white');
$arguments = array(0.50);
$imagick2->functionImage(Imagick::FUNCTION_SINUSOID$arguments);
$imagick1->compositeimage($imagick2Imagick::COMPOSITE_MULTIPLY00);

header("Content-Type: image/png");
$imagick1->setImageFormat("png");
echo 
$imagick1->getImageBlob();
?>

以上例程的输出类似于:

Output of create complex gradient
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

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

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